int NwpRegisterInterruptHandler(P_EVENT_HANDLER InterruptHdl , void* pValue) //do not know what to do with pValue { if(InterruptHdl == NULL) { //De-register Interprocessor communication interrupt between App and NWP #ifdef SL_PLATFORM_MULTI_THREADED osi_InterruptDeRegister(INT_NWPIC); #else MAP_IntDisable(INT_NWPIC); MAP_IntUnregister(INT_NWPIC); MAP_IntPendClear(INT_NWPIC); #endif } else { #ifdef SL_PLATFORM_MULTI_THREADED MAP_IntPendClear(INT_NWPIC); osi_InterruptRegister(INT_NWPIC, (P_OSI_INTR_ENTRY)InterruptHdl, INT_PRIORITY_LVL_1); #else MAP_IntRegister(INT_NWPIC, InterruptHdl); MAP_IntPrioritySet(INT_NWPIC, INT_PRIORITY_LVL_1); MAP_IntPendClear(INT_NWPIC); MAP_IntEnable(INT_NWPIC); #endif } return 0; }
//**************************************************************************** // //! 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; }
void Button_IF_EnableInterrupt(unsigned char ucSwitch) { if(ucSwitch & SW2) { //Enable GPIO Interrupt MAP_GPIOIntClear(GPIOA2_BASE,GPIO_PIN_6); MAP_IntPendClear(INT_GPIOA2); MAP_IntEnable(INT_GPIOA2); MAP_GPIOIntEnable(GPIOA2_BASE,GPIO_PIN_6); } if(ucSwitch & SW3) { //Enable GPIO Interrupt MAP_GPIOIntClear(GPIOA1_BASE,GPIO_PIN_5); MAP_IntPendClear(INT_GPIOA1); MAP_IntEnable(INT_GPIOA1); MAP_GPIOIntEnable(GPIOA1_BASE,GPIO_PIN_5); } }
//***************************************************************************** // //! MicroPhone Control Routine //! //! \param pValue - pointer to a memory structure that is passed //! to the interrupt handler. //! //! \return None // //***************************************************************************** void MicroPhoneControl(void* pValue) { int iCount=0; unsigned long ulPin5Val = 1; //Check whether GPIO Level is Stable As No Debouncing Circuit in LP for(iCount=0;iCount<3;iCount++) { osi_Sleep(200); ulPin5Val = MAP_GPIOPinRead(GPIOA1_BASE,GPIO_PIN_5); if(ulPin5Val) { //False Alarm return; } } if (g_ucMicStartFlag == 0) { for(iCount = 0; iCount<3; iCount++) { //Blink LED 3 times to Indicate ON GPIO_IF_LedOff(MCU_GREEN_LED_GPIO); osi_Sleep(50); GPIO_IF_LedOn(MCU_GREEN_LED_GPIO); osi_Sleep(50); } g_ucMicStartFlag = 1; } else { //Blink LED 3 times to Indicate OFF for(iCount = 0; iCount<3; iCount++) { GPIO_IF_LedOn(MCU_GREEN_LED_GPIO); osi_Sleep(50); GPIO_IF_LedOff(MCU_GREEN_LED_GPIO); osi_Sleep(50); } g_ucMicStartFlag = 0; } //Enable GPIO Interrupt MAP_GPIOIntClear(GPIOA1_BASE,GPIO_PIN_5); MAP_IntPendClear(INT_GPIOA1); MAP_IntEnable(INT_GPIOA1); MAP_GPIOIntEnable(GPIOA1_BASE,GPIO_PIN_5); }
/* Zephyr has no function for clearing an interrupt, so use driverlib: */ void HwiP_clearInterrupt(int interruptNum) { MAP_IntPendClear((unsigned long)interruptNum); }
void SpeakerControl(void* pValue) { int iCount=0; unsigned long ulPin6Val = 1; long lRetVal = -1; //Check whether GPIO Level is Stable As No Debouncing Circuit in LP for(iCount=0;iCount<3;iCount++) { osi_Sleep(200); ulPin6Val = MAP_GPIOPinRead(GPIOA2_BASE,GPIO_PIN_6); if(ulPin6Val) { //False Alarm return; } } if (g_ucSpkrStartFlag == 0) { #ifndef MULTICAST //Un Register mDNS Service. lRetVal = sl_NetAppMDNSUnRegisterService((signed char *)CC3200_MDNS_NAME,\ (unsigned char)strlen((const char *)CC3200_MDNS_NAME)); if(lRetVal < 0) { UART_PRINT("Unable to unregister MDNS service\n\r"); } //Registering for the mDNS service. lRetVal = sl_NetAppMDNSRegisterService((signed char *)CC3200_MDNS_NAME, \ (unsigned char)strlen((const char *)CC3200_MDNS_NAME),\ (signed char *)"multicast",\ (unsigned char)strlen((const char *)"multicast"),\ AUDIO_PORT,1000,0); if(lRetVal < 0) { UART_PRINT("Unable to register MDNS service\n\r"); LOOP_FOREVER(); } #endif //Blink LED 3 times to Indicate ON for(iCount = 0; iCount<3; iCount++) { GPIO_IF_LedOff(MCU_ORANGE_LED_GPIO); osi_Sleep(50); GPIO_IF_LedOn(MCU_ORANGE_LED_GPIO); osi_Sleep(50); } g_ucSpkrStartFlag = 1; } else { //Un Register mDNS Service. lRetVal = sl_NetAppMDNSUnRegisterService((signed char *)CC3200_MDNS_NAME,\ (unsigned char)strlen((const char *)CC3200_MDNS_NAME)); if(lRetVal < 0) { UART_PRINT("Unable to unregister MDNS service\n\r"); } //Blink LED 3 times to Indicate OFF for(iCount = 0; iCount<3; iCount++) { GPIO_IF_LedOn(MCU_ORANGE_LED_GPIO); osi_Sleep(50); GPIO_IF_LedOff(MCU_ORANGE_LED_GPIO); osi_Sleep(50); } g_ucSpkrStartFlag = 0; } //Enable GPIO Interrupt MAP_GPIOIntClear(GPIOA2_BASE,GPIO_PIN_6); MAP_IntPendClear(INT_GPIOA2); MAP_IntEnable(INT_GPIOA2); MAP_GPIOIntEnable(GPIOA2_BASE,GPIO_PIN_6); }