//**************************************************************************** // //! Main function //! //! \param none //! //! This function //! 1. Configures the GPIOA1 and A2 interrupt. //! //! \return None. // //**************************************************************************** int main() { // // Initialize Board configurations // BoardInit(); // // Power on the corresponding GPIO port B for 9,10,11. // Set up the GPIO lines to mode 0 (GPIO) // PinMuxConfig(); // // Configure the GPIO13 - SW2 interrupt // MAP_GPIOIntRegister(GPIOA1_BASE, GPIOA1IntHandler); MAP_GPIOIntTypeSet(GPIOA1_BASE, GPIO_PIN_5, GPIO_RISING_EDGE); // // Configure the GPIO22 interrupt // MAP_GPIOIntRegister(GPIOA2_BASE, GPIOA2IntHandler); MAP_GPIOIntTypeSet(GPIOA2_BASE, GPIO_PIN_6, GPIO_RISING_EDGE); // // Enable GPIO13 Interrupt // MAP_GPIOIntClear(GPIOA1_BASE, GPIO_PIN_5); MAP_IntPendClear(INT_GPIOA1); MAP_IntEnable(INT_GPIOA1); MAP_GPIOIntEnable(GPIOA1_BASE, GPIO_PIN_5); // // Enable GPIO22 Interrupt // MAP_GPIOIntClear(GPIOA2_BASE, GPIO_PIN_6); MAP_IntPendClear(INT_GPIOA2); MAP_IntEnable(INT_GPIOA2); MAP_GPIOIntEnable(GPIOA2_BASE, GPIO_PIN_6); // // Infinite loop. All processing happens now in the interrupt handler. while (1) { } return 0; }
//**************************************************************************** // //! Configures the GPIO selected as input to generate interrupt on activity //! //! \param uiGPIOPort is the GPIO port address //! \param ucGPIOPin is the GPIO pin of the specified port //! \param uiIntType is the type of the interrupt (refer gpio.h) //! \param pfnIntHandler is the interrupt handler to register //! //! This function //! 1. Sets GPIO interrupt type //! 2. Registers Interrupt handler //! 3. Enables Interrupt //! //! \return None // //**************************************************************************** void GPIO_IF_ConfigureNIntEnable(unsigned int uiGPIOPort, unsigned char ucGPIOPin, unsigned int uiIntType, void (*pfnIntHandler)(void)) { // // Set GPIO interrupt type // MAP_GPIOIntTypeSet(uiGPIOPort,ucGPIOPin,uiIntType); // // Register Interrupt handler // #ifdef USE_TIRTOS osi_InterruptRegister(GetPeripheralIntNum(uiGPIOPort), pfnIntHandler, INT_PRIORITY_LVL_1); #else MAP_GPIOIntRegister(uiGPIOPort,pfnIntHandler); #endif // // Enable Interrupt // MAP_GPIOIntClear(uiGPIOPort,ucGPIOPin); MAP_GPIOIntEnable(uiGPIOPort,ucGPIOPin); }
//**************************************************************************** // //! Configures the GPIO selected as input to generate interrupt on activity //! //! \param uiGPIOPort is the GPIO port address //! \param ucGPIOPin is the GPIO pin of the specified port //! \param uiIntType is the type of the interrupt (refer gpio.h) //! \param pfnIntHandler is the interrupt handler to register //! //! This function //! 1. Sets GPIO interrupt type //! 2. Registers Interrupt handler //! 3. Enables Interrupt //! //! \return None // //**************************************************************************** void GPIO_IF_ConfigureNIntEnable(unsigned int uiGPIOPort, unsigned char ucGPIOPin, unsigned int uiIntType, void (*pfnIntHandler)(void)) { // // Set GPIO interrupt type // MAP_GPIOIntTypeSet(uiGPIOPort,ucGPIOPin,uiIntType); // // Register Interrupt handler // #if defined(USE_TIRTOS) || defined(USE_FREERTOS) || defined(SL_PLATFORM_MULTI_THREADED) // USE_TIRTOS: if app uses TI-RTOS (either networking/non-networking) // USE_FREERTOS: if app uses Free-RTOS (either networking/non-networking) // SL_PLATFORM_MULTI_THREADED: if app uses any OS + networking(simplelink) osi_InterruptRegister(GetPeripheralIntNum(uiGPIOPort), pfnIntHandler, INT_PRIORITY_LVL_1); #else MAP_IntPrioritySet(GetPeripheralIntNum(uiGPIOPort), INT_PRIORITY_LVL_1); MAP_GPIOIntRegister(uiGPIOPort,pfnIntHandler); #endif // // Enable Interrupt // MAP_GPIOIntClear(uiGPIOPort,ucGPIOPin); MAP_GPIOIntEnable(uiGPIOPort,ucGPIOPin); }
STATIC void pin_extint_register(pin_obj_t *self, uint32_t intmode, uint32_t priority) { void *handler; uint32_t intnum; // configure the interrupt type MAP_GPIOIntTypeSet(self->port, self->bit, intmode); switch (self->port) { case GPIOA0_BASE: handler = GPIOA0IntHandler; intnum = INT_GPIOA0; break; case GPIOA1_BASE: handler = GPIOA1IntHandler; intnum = INT_GPIOA1; break; case GPIOA2_BASE: handler = GPIOA2IntHandler; intnum = INT_GPIOA2; break; case GPIOA3_BASE: default: handler = GPIOA3IntHandler; intnum = INT_GPIOA3; break; } MAP_GPIOIntRegister(self->port, handler); // set the interrupt to the lowest priority, to make sure that // no other ISRs will be preemted by this one MAP_IntPrioritySet(intnum, priority); }