void HWGPIO_Config(void) { /* Configure P3.2 as EINT0 pin and enable interrupt by falling edge trigger */ GPIO_SetMode(P3, BIT2, GPIO_PMD_INPUT); GPIO_EnableEINT0(P3, 2, GPIO_INT_BOTH_EDGE); NVIC_EnableIRQ(EINT0_IRQn); /* Enable interrupt de-bounce function and select de-bounce sampling cycle time is 10 KHz clock */ GPIO_SET_DEBOUNCE_TIME(GPIO_DBCLKSRC_LIRC, GPIO_DBCLKSEL_1); GPIO_ENABLE_DEBOUNCE(P3, BIT2); }
/** * @brief Main routine. * @param None. * @return None. */ int32_t main(void) { SYS_UnlockReg(); SYS->P5_MFP = (SYS->P5_MFP & 0x00FFFCFC) | 0x03; /* P5.1 -> XTAL2, P5.0 -> XTAL1 */ CLK->PWRCON = CLK_PWRCON_XTL12M | 4 | 8 ; SYS_Init(); /* SPI test */ LCD_Init(); LCD_EnableBackLight(); LCD_ClearScreen(); LCD_Print(0, "Welcome! Nuvoton"); LCD_Print(1, "This is LB board"); LCD_Print(2, "Mini51"); LCD_Print(3, "TEST"); // backlight control pin P5.4 GPIO_SetMode(P5,1<<4,GPIO_PMD_OUTPUT); /* INT button triggers P3.2 */ GPIO_SetMode(P3,(1<<2),GPIO_PMD_OPEN_DRAIN); GPIO_EnableInt(P3, 2, GPIO_INT_FALLING); NVIC_EnableIRQ(EINT0_IRQn); /* Enable interrupt de-bounce function and select de-bounce sampling cycle time */ GPIO_SET_DEBOUNCE_TIME(GPIO_DBNCECON_DBCLKSRC_HCLK,GPIO_DBNCECON_DBCLKSEL_16); GPIO_ENABLE_DEBOUNCE(P3,1<<2); /* Reset and stop TIMER0, TIMER1 counting first */ TIMER1->TCSR = TIMER_TCSR_CRST_Msk; /* Enable TIMER0, TIMER1, NVIC */ NVIC_EnableIRQ(TMR1_IRQn); /* To Configure TCMPR values based on Timer clock source and pre-scale value */ TIMER_SET_PRESCALE_VALUE(TIMER1,0); /* Start TIMER1 counting and setting*/ TIMER_Open(TIMER1,TIMER_PERIODIC_MODE,SystemCoreClock/1000); TIMER_EnableInt(TIMER1); while(1) ; // loop forever }
/*---------------------------------------------------------------------------------------------------------*/ int main(void) { /* Unlock protected registers */ SYS_UnlockReg(); /* Init System, peripheral clock and multi-function I/O */ SYS_Init(); /* Lock protected registers */ SYS_LockReg(); /* Init UART0 for printf */ UART0_Init(); printf("\n\nCPU @ %d Hz\n", SystemCoreClock); printf("+-------------------------------------------------------+\n"); printf("| GPIO Power-Down and Wake-up by PB.3 Sample Code |\n"); printf("+-------------------------------------------------------+\n\n"); /* Configure PB.3 as Input mode and enable interrupt by rising edge trigger */ GPIO_SetMode(PB, BIT3, GPIO_MODE_INPUT); GPIO_EnableInt(PB, 3, GPIO_INT_RISING); NVIC_EnableIRQ(GPB_IRQn); /* Enable interrupt de-bounce function and select de-bounce sampling cycle time is 1024 clocks of LIRC clock */ GPIO_SET_DEBOUNCE_TIME(GPIO_DBCTL_DBCLKSRC_LIRC, GPIO_DBCTL_DBCLKSEL_1024); GPIO_ENABLE_DEBOUNCE(PB, BIT3); /* Unlock protected registers before entering Power-down mode */ SYS_UnlockReg(); /* Waiting for PB.3 rising-edge interrupt event */ while(1) { printf("Enter to Power-Down ......\n"); /* Enter to Power-down mode */ PowerDownFunction(); printf("System waken-up done.\n\n"); } }
/*---------------------------------------------------------------------------------------------------------*/ int main(void) { /* Unlock protected registers */ SYS_UnlockReg(); /* Init System, peripheral clock and multi-function I/O */ SYS_Init(); /* Lock protected registers */ SYS_LockReg(); /* Init UART0 for printf */ UART0_Init(); printf("\n\nCPU @ %d Hz\n", SystemCoreClock); printf("+------------------------------------------------------------+\n"); printf("| GPIO EINT0/EINT1 Interrupt and De-bounce Sample Code |\n"); printf("+------------------------------------------------------------+\n\n"); /*-----------------------------------------------------------------------------------------------------*/ /* GPIO External Interrupt Function Test */ /*-----------------------------------------------------------------------------------------------------*/ printf("EINT0(PB.14) and EINT1(PB.15) are used to test interrupt\n"); /* Configure PB.14 as EINT0 pin and enable interrupt by falling edge trigger */ GPIO_SetMode(PB, BIT14, GPIO_PMD_INPUT); GPIO_EnableEINT0(PB, 14, GPIO_INT_FALLING); NVIC_EnableIRQ(EINT0_IRQn); /* Configure PB.15 as EINT1 pin and enable interrupt by rising and falling edge trigger */ GPIO_SetMode(PB, BIT15, GPIO_PMD_INPUT); GPIO_EnableEINT1(PB, 15, GPIO_INT_BOTH_EDGE); NVIC_EnableIRQ(EINT1_IRQn); /* Enable interrupt de-bounce function and select de-bounce sampling cycle time is 1024 * 10 KHz clock */ GPIO_SET_DEBOUNCE_TIME(GPIO_DBCLKSRC_LIRC, GPIO_DBCLKSEL_1024); GPIO_ENABLE_DEBOUNCE(PB, BIT14 | BIT15); /* Waiting for interrupts */ while(1); }
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id) { if (pin == NC) { return -1; } uint32_t pin_index = NU_PINNAME_TO_PIN(pin); uint32_t port_index = NU_PINNAME_TO_PORT(pin); if (pin_index >= NU_MAX_PIN_PER_PORT || port_index >= NU_MAX_PORT) { return -1; } obj->pin = pin; obj->irq_handler = (uint32_t) handler; obj->irq_id = id; GPIO_T *gpio_base = NU_PORT_BASE(port_index); //gpio_set(pin); #if NUC472_GPIO_IRQ_DEBOUNCE_ENABLE // Configure de-bounce clock source and sampling cycle time GPIO_SET_DEBOUNCE_TIME(NUC472_GPIO_IRQ_DEBOUNCE_CLOCK_SOURCE, NUC472_GPIO_IRQ_DEBOUNCE_SAMPLE_RATE); GPIO_ENABLE_DEBOUNCE(gpio_base, 1 << pin_index); #else GPIO_DISABLE_DEBOUNCE(gpio_base, 1 << pin_index); #endif struct nu_gpio_irq_var *var = gpio_irq_var_arr + port_index; var->obj_arr[pin_index] = obj; // NOTE: InterruptIn requires IRQ enabled by default. gpio_irq_enable(obj); return 0; }
//========================================================================= //----- (00005D24) -------------------------------------------------------- __myevic__ void DevicesOnOff( int off ) { if ( off ) { TIMER_DisableInt( TIMER0 ); TIMER_DisableInt( TIMER1 ); TIMER_DisableInt( TIMER2 ); if ( !gFlags.light_sleep ) { TIMER_DisableInt( TIMER3 ); } EADC_Close( EADC ); SetADCState( 1, 0 ); SetADCState( 2, 0 ); SetADCState( 14, 0 ); if ( ISVTCDUAL || ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 ) { SetADCState( 3, 0 ); SetADCState( 13, 0 ); if ( ISCUBO200 || ISRX200S || ISRX23 || ISRX300 ) { SetADCState( 15, 0 ); } PD7 = 0; BBC_Configure( BBC_PWMCH_CHARGER, 0 ); PD7 = 0; if ( ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 ) { PF2 = 0; } } PC1 = 0; PC0 = 0; BBC_Configure( BBC_PWMCH_BUCK, 0 ); if ( !ISVTCDUAL ) PC3 = 0; PC2 = 0; BBC_Configure( BBC_PWMCH_BOOST, 0 ); if ( ISCUBO200 || ISRX200S || ISRX23 ) { PF1 = 0; } else if ( ISRX300 ) { PD1 = 0; } else { PB7 = 0; } GPIO_DisableInt( PD, 0 ); PD0 = 0; GPIO_SetMode( PD, GPIO_PIN_PIN0_Msk, GPIO_MODE_OUTPUT ); if ( ISRX300 ) { PF5 = 0; PF6 = 0; PA3 = 0; PA2 = 0; } if ( ISVTCDUAL ) { GPIO_DisableInt( PD, 1 ); PD1 = 0; GPIO_SetMode( PD, GPIO_PIN_PIN1_Msk, GPIO_MODE_OUTPUT ); } else if ( !ISCUBOID && !ISCUBO200 && !ISRX200S && !ISRX23 && !ISRX300 ) { GPIO_DisableInt( PD, 7 ); PD7 = 0; GPIO_SetMode( PD, GPIO_PIN_PIN7_Msk, GPIO_MODE_OUTPUT ); } SYS->GPE_MFPH &= ~(SYS_GPE_MFPH_PE11MFP_Msk|SYS_GPE_MFPH_PE12MFP_Msk|SYS_GPE_MFPH_PE13MFP_Msk); SYS->GPE_MFPH |= (SYS_GPE_MFPH_PE11MFP_GPIO|SYS_GPE_MFPH_PE12MFP_GPIO|SYS_GPE_MFPH_PE13MFP_GPIO); PE11 = 0; GPIO_SetMode( PE, GPIO_PIN_PIN11_Msk, GPIO_MODE_OUTPUT ); PE12 = 0; GPIO_SetMode( PE, GPIO_PIN_PIN12_Msk, GPIO_MODE_OUTPUT ); PE13 = 0; GPIO_SetMode( PE, GPIO_PIN_PIN13_Msk, GPIO_MODE_OUTPUT ); PE10 = 0; GPIO_EnableInt( PE, 0, GPIO_INT_BOTH_EDGE ); GPIO_EnableInt( PD, 2, GPIO_INT_BOTH_EDGE ); GPIO_EnableInt( PD, 3, GPIO_INT_BOTH_EDGE ); if ( ISVTCDUAL ) { PA3 = 0; PC3 = 0; PF2 = 0; PA2 = 0; } else if ( ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 ) { PF0 = 0; } SYS_UnlockReg(); SYS->USBPHY &= ~SYS_USBPHY_LDO33EN_Msk; SYS->IVSCTL &= ~(SYS_IVSCTL_VBATUGEN_Msk|SYS_IVSCTL_VTEMPEN_Msk); SYS_DisableBOD(); SYS->VREFCTL = 0; SYS_LockReg(); USBD_CLR_INT_FLAG( USBD_INTSTS_WAKEUP|USBD_INTSTS_FLDET|USBD_INTSTS_BUS|USBD_INTSTS_USB ); USBD_ENABLE_INT( USBD_INT_WAKEUP ); } else { USBD_CLR_INT_FLAG( USBD_INTSTS_WAKEUP ); SYS_UnlockReg(); SYS->USBPHY |= SYS_USBPHY_LDO33EN_Msk; SYS->IVSCTL |= SYS_IVSCTL_VBATUGEN_Msk; if ( ISRX300 ) { SYS->IVSCTL |= SYS_IVSCTL_VTEMPEN_Msk; } SYS->VREFCTL = SYS_VREFCTL_VREF_2_56V; SYS_EnableBOD( SYS_BODCTL_BOD_RST_EN, SYS_BODCTL_BODVL_2_2V ); SYS_LockReg(); GPIO_DisableInt( PE, 0 ); GPIO_DisableInt( PD, 2 ); GPIO_DisableInt( PD, 3 ); if ( ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 ) { PF2 = 1; } SYS->GPE_MFPH &= ~(SYS_GPE_MFPH_PE11MFP_Msk|SYS_GPE_MFPH_PE12MFP_Msk|SYS_GPE_MFPH_PE13MFP_Msk); SYS->GPE_MFPH |= (SYS_GPE_MFPH_PE11MFP_SPI0_MOSI0|SYS_GPE_MFPH_PE12MFP_SPI0_SS|SYS_GPE_MFPH_PE13MFP_SPI0_CLK); GPIO_SetMode( PD, GPIO_PIN_PIN0_Msk, GPIO_MODE_INPUT ); GPIO_EnableInt( PD, 0, GPIO_INT_FALLING ); if ( ISVTCDUAL ) { GPIO_SetMode( PD, GPIO_PIN_PIN1_Msk, GPIO_MODE_INPUT ); GPIO_EnableInt( PD, 1, GPIO_INT_RISING ); GPIO_ENABLE_DEBOUNCE( PD, GPIO_PIN_PIN1_Msk ); } else if ( !ISCUBOID && !ISCUBO200 && !ISRX200S && !ISRX23 && !ISRX300 ) { GPIO_SetMode( PD, GPIO_PIN_PIN7_Msk, GPIO_MODE_INPUT ); GPIO_EnableInt( PD, 7, GPIO_INT_RISING ); GPIO_ENABLE_DEBOUNCE( PD, GPIO_PIN_PIN7_Msk ); } if ( ISCUBO200 || ISRX200S || ISRX23 ) { PF1 = 1; } else if ( ISRX300 ) { PD1 = 1; } else { PB7 = 1; } SetADCState( 1, 1 ); SetADCState( 2, 1 ); SetADCState( 14, 1 ); if ( ISVTCDUAL || ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 ) { SetADCState( 3, 1 ); SetADCState( 13, 1 ); if ( ISCUBO200 || ISRX200S || ISRX23 || ISRX300 ) { SetADCState( 15, 1 ); } } TIMER_EnableInt( TIMER0 ); TIMER_EnableInt( TIMER1 ); TIMER_EnableInt( TIMER2 ); TIMER_EnableInt( TIMER3 ); } }
void key_init() { KeyDev.DevDesc.DevDesc_leng = 26; //Report descriptor KeyDev.DevDesc.RptDesc_leng = 22; //Report descriptor KeyDev.DevDesc.InRptLeng = 3; //Input report KeyDev.DevDesc.OutRptLeng = 0; //Output report KeyDev.DevDesc.GetFeatLeng = 4; //Get feature KeyDev.DevDesc.SetFeatLeng = 4; //Set feature KeyDev.DevDesc.CID = 0; //manufacturers ID KeyDev.DevDesc.DID = 0; //Product ID KeyDev.DevDesc.PID = 0; //Device firmware revision KeyDev.DevDesc.UID = 0; //Device Class type KeyDev.DevDesc.UCID = 0; //reserve /* Feature */ KeyDev.Feature.data1.minimum = 0; //Sleep period KeyDev.Feature.data1.maximum = 1024; KeyDev.Feature.data1.value = 100; KeyDev.Feature.arg[0] = 1; KeyDev.Feature.datalen[0] = 2; KeyDev.Feature.dataNum = 1; /* Input */ KeyDev.Input.data1.minimum = 0; //sensored disance KeyDev.Input.data1.maximum = 127; KeyDev.Input.data1.value = 0; KeyDev.Input.arg[0] = 1; KeyDev.Input.datalen[0] = 2; KeyDev.Input.dataNum = 1; /* Output */ KeyDev.Output.dataNum = 0; /* Configure PC.0 as Input mode and enable interrupt by rising edge trigger */ SYS->GPC_MFPL &= ~SYS_GPC_MFPL_PC0MFP_Msk; SYS->GPC_MFPL |= SYS_GPC_MFPL_PC0MFP_GPIO; GPIO_SetMode(PC, BIT0, GPIO_MODE_QUASI); GPIO_EnableInt(PC, 0, GPIO_INT_BOTH_EDGE); /* Configure PC.1 as Input mode and enable interrupt by rising edge trigger */ SYS->GPC_MFPL &= ~SYS_GPC_MFPL_PC1MFP_Msk; SYS->GPC_MFPL |= SYS_GPC_MFPL_PC1MFP_GPIO; GPIO_SetMode(PC, BIT1, GPIO_MODE_QUASI); GPIO_EnableInt(PC, 1, GPIO_INT_BOTH_EDGE); /* Configure PC.2 as Input mode and enable interrupt by rising edge trigger */ SYS->GPC_MFPL &= ~SYS_GPC_MFPL_PC2MFP_Msk; SYS->GPC_MFPL |= SYS_GPC_MFPL_PC2MFP_GPIO; GPIO_SetMode(PC, BIT2, GPIO_MODE_QUASI); GPIO_EnableInt(PC, 2, GPIO_INT_BOTH_EDGE); /* Configure PC.3 as Input mode and enable interrupt by rising edge trigger */ SYS->GPC_MFPL &= ~SYS_GPC_MFPL_PC3MFP_Msk; SYS->GPC_MFPL |= SYS_GPC_MFPL_PC3MFP_GPIO; GPIO_SetMode(PC, BIT3, GPIO_MODE_QUASI); GPIO_EnableInt(PC, 3, GPIO_INT_BOTH_EDGE); /* Configure PC.4 as Input mode and enable interrupt by rising edge trigger */ SYS->GPC_MFPL &= ~SYS_GPC_MFPL_PC4MFP_Msk; SYS->GPC_MFPL |= SYS_GPC_MFPL_PC4MFP_GPIO; GPIO_SetMode(PC, BIT4, GPIO_MODE_QUASI); GPIO_EnableInt(PC, 4, GPIO_INT_BOTH_EDGE); /* Configure PC.5 as Quasi-bidirection mode and enable interrupt by falling edge trigger */ SYS->GPC_MFPL &= ~SYS_GPC_MFPL_PC5MFP_Msk; SYS->GPC_MFPL |= SYS_GPC_MFPL_PC5MFP_GPIO; GPIO_SetMode(PC, BIT5, GPIO_MODE_QUASI); GPIO_EnableInt(PC, 5, GPIO_INT_BOTH_EDGE); /* Configure PC.6 as Quasi-bidirection mode and enable interrupt by falling edge trigger */ SYS->GPC_MFPL &= ~SYS_GPC_MFPL_PC6MFP_Msk; SYS->GPC_MFPL |= SYS_GPC_MFPL_PC6MFP_GPIO; GPIO_SetMode(PC, BIT6, GPIO_MODE_QUASI); GPIO_EnableInt(PC, 6, GPIO_INT_BOTH_EDGE); NVIC_EnableIRQ(GPC_IRQn); /* Configure PE.0 as Quasi-bidirection mode and enable interrupt by falling edge trigger */ /* Configure PC.3 as Input mode and enable interrupt by rising edge trigger */ SYS->GPE_MFPL &= ~SYS_GPE_MFPL_PE0MFP_Msk; SYS->GPE_MFPL |= SYS_GPE_MFPL_PE0MFP_GPIO; GPIO_SetMode(PE, BIT0, GPIO_MODE_QUASI); GPIO_EnableInt(PE, 0, GPIO_INT_BOTH_EDGE); NVIC_EnableIRQ(GPE_IRQn); //LED SYS->GPA_MFPL &= ~(SYS_GPA_MFPL_PA2MFP_Msk); SYS->GPA_MFPL |= SYS_GPA_MFPL_PA2MFP_GPIO; GPIO_SetMode(PA,BIT2,GPIO_MODE_OUTPUT); PA2 = 1; /* Enable interrupt de-bounce function and select de-bounce sampling cycle time is 1024 clocks of LIRC clock */ GPIO_SET_DEBOUNCE_TIME(GPIO_DBCTL_DBCLKSRC_LIRC, GPIO_DBCTL_DBCLKSEL_1024); GPIO_ENABLE_DEBOUNCE(PC, BIT0); GPIO_ENABLE_DEBOUNCE(PC, BIT1); GPIO_ENABLE_DEBOUNCE(PC, BIT2); GPIO_ENABLE_DEBOUNCE(PC, BIT3); GPIO_ENABLE_DEBOUNCE(PC, BIT4); GPIO_ENABLE_DEBOUNCE(PC, BIT5); GPIO_ENABLE_DEBOUNCE(PE, BIT0); keyState = 0; }
//========================================================================= //----- (00002384) -------------------------------------------------------- __myevic__ void InitGPIO() { if ( ISVTCDUAL ) { PA3 = 0; GPIO_SetMode( PA, GPIO_PIN_PIN3_Msk, GPIO_MODE_OUTPUT ); } if ( ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 ) { SYS->GPF_MFPL &= ~SYS_GPF_MFPL_PF0MFP_Msk; SYS->GPF_MFPL |= SYS_GPF_MFPL_PF0MFP_GPIO; PF0 = 0; GPIO_SetMode( PF, GPIO_PIN_PIN0_Msk, GPIO_MODE_OUTPUT ); } // PD1 = Data transmitter output pin for UART0 #if (ENABLE_UART) SYS->GPD_MFPL |= SYS_GPD_MFPL_PD1MFP_UART0_TXD; #endif if ( ISRX300 ) { SYS->GPD_MFPL &= ~(SYS_GPD_MFPL_PD0MFP_Msk|SYS_GPD_MFPL_PD1MFP_Msk); SYS->GPD_MFPL |= SYS_GPD_MFPL_PD0MFP_GPIO|SYS_GPD_MFPL_PD1MFP_GPIO; } // PC0 = PWM0 CH0 BBC_Configure( BBC_PWMCH_BUCK, 1 ); // PC2 = PWM0 CH2 BBC_Configure( BBC_PWMCH_BOOST, 1 ); if ( ISVTCDUAL || ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 ) { PD7 = 0; BBC_Configure( BBC_PWMCH_CHARGER, 0 ); PD7 = 0; } // BUTTONS GPIO_SetMode( PE, GPIO_PIN_PIN0_Msk, GPIO_MODE_INPUT ); GPIO_SetMode( PD, GPIO_PIN_PIN2_Msk, GPIO_MODE_INPUT ); GPIO_SetMode( PD, GPIO_PIN_PIN3_Msk, GPIO_MODE_INPUT ); if ( ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 ) { PF2 = 1; GPIO_SetMode( PF, GPIO_PIN_PIN2_Msk, GPIO_MODE_OUTPUT ); } else if ( ISRX300 ) { SYS->GPF_MFPL &= ~(SYS_GPF_MFPL_PF5MFP_Msk|SYS_GPF_MFPL_PF6MFP_Msk); SYS->GPF_MFPL |= SYS_GPF_MFPL_PF5MFP_GPIO|SYS_GPF_MFPL_PF6MFP_GPIO; PF5 = 0; GPIO_SetMode( PF, GPIO_PIN_PIN5_Msk, GPIO_MODE_OUTPUT ); PF6 = 0; GPIO_SetMode( PF, GPIO_PIN_PIN6_Msk, GPIO_MODE_OUTPUT ); PA3 = 0; GPIO_SetMode( PA, GPIO_PIN_PIN3_Msk, GPIO_MODE_OUTPUT ); PA2 = 0; GPIO_SetMode( PA, GPIO_PIN_PIN2_Msk, GPIO_MODE_OUTPUT ); } // BUCK/BOOST CONVERTER CONTROL LINES PC1 = 0; GPIO_SetMode( PC, GPIO_PIN_PIN1_Msk, GPIO_MODE_OUTPUT ); PC3 = 0; GPIO_SetMode( PC, GPIO_PIN_PIN3_Msk, GPIO_MODE_OUTPUT ); // SSD RESET/VDD/VCC PA0 = 0; GPIO_SetMode( PA, GPIO_PIN_PIN0_Msk, GPIO_MODE_OUTPUT ); PA1 = 0; GPIO_SetMode( PA, GPIO_PIN_PIN1_Msk, GPIO_MODE_OUTPUT ); PC4 = 0; GPIO_SetMode( PC, GPIO_PIN_PIN4_Msk, GPIO_MODE_OUTPUT ); // BATTERY GPIO_SetMode( PD, GPIO_PIN_PIN0_Msk, GPIO_MODE_INPUT ); GPIO_EnableInt( PD, 0, GPIO_INT_FALLING ); if ( ISVTCDUAL ) { PA2 = 0; GPIO_SetMode( PA, GPIO_PIN_PIN2_Msk, GPIO_MODE_OUTPUT ); PF2 = 0; GPIO_SetMode( PF, GPIO_PIN_PIN2_Msk, GPIO_MODE_OUTPUT ); GPIO_SetMode( PD, GPIO_PIN_PIN1_Msk, GPIO_MODE_INPUT ); GPIO_EnableInt( PD, 1, GPIO_INT_RISING ); GPIO_ENABLE_DEBOUNCE( PD, GPIO_PIN_PIN1_Msk ); } else if ( !ISCUBOID && !ISCUBO200 && !ISRX200S && !ISRX23 && !ISRX300 ) { GPIO_SetMode( PD, GPIO_PIN_PIN7_Msk, GPIO_MODE_INPUT ); GPIO_EnableInt( PD, 7, GPIO_INT_RISING ); GPIO_ENABLE_DEBOUNCE( PD, GPIO_PIN_PIN7_Msk ); } // SPI0 (Display control) PE10 = 0; GPIO_SetMode( PE, GPIO_PIN_PIN10_Msk, GPIO_MODE_OUTPUT ); PE12 = 0; GPIO_SetMode( PE, GPIO_PIN_PIN12_Msk, GPIO_MODE_OUTPUT ); // LED Control if ( ISEGRIPII || ISEVICAIO ) { PB3 = 0; // Blue PB4 = 0; // Red PB5 = 0; // Green GPIO_SetMode( PB, GPIO_PIN_PIN3_Msk|GPIO_PIN_PIN4_Msk|GPIO_PIN_PIN5_Msk, GPIO_MODE_OUTPUT ); } if ( ISCUBO200 || ISRX200S || ISRX23 ) { SYS->GPF_MFPL &= ~SYS_GPF_MFPL_PF1MFP_Msk; SYS->GPF_MFPL |= SYS_GPF_MFPL_PF1MFP_GPIO; PF1 = 1; GPIO_SetMode( PF, GPIO_PIN_PIN1_Msk, GPIO_MODE_OUTPUT ); } else if ( ISRX300 ) { SYS->GPD_MFPL &= ~SYS_GPD_MFPL_PD1MFP_Msk; SYS->GPD_MFPL |= SYS_GPD_MFPL_PD1MFP_GPIO; PD1 = 1; GPIO_SetMode( PD, GPIO_PIN_PIN1_Msk, GPIO_MODE_OUTPUT ); } else { // ? (What is PB.7?) PB7 = 1; GPIO_SetMode( PB, GPIO_PIN_PIN7_Msk, GPIO_MODE_OUTPUT ); } NVIC_EnableIRQ( GPD_IRQn ); NVIC_EnableIRQ( GPE_IRQn ); NVIC_EnableIRQ( GPF_IRQn ); // Debounce time = 100ms GPIO_SET_DEBOUNCE_TIME( GPIO_DBCTL_DBCLKSRC_LIRC, GPIO_DBCTL_DBCLKSEL_1024 ); }