I am using CCS for cc2640. I am trying to add a GPIO interrupt to sample project "SimpleBLEPeripheral". I followed swru393, the cc26xx software developer guide, section 6.3.1, page 81 to set a GPIO interrupt. But the interrupt does not work. The pin's input can be read correctly by polling with PIN_getIntputValue. However, it never triggers interrupt when I press the button. I have a button connected to ground and a GPIO, I set the GPIO with input enabled, internal pull up resistor, and set the interrupt triggered on negative edge, which is when I press the button. Can anyone help me? Please do not suggest me to refer to SimpleBLECentral or Sensortag's interrupt as I have done that. Thanks.
Following is the code I added to SimpleBLEPeripheral, with reference from cc26xx software developer guide.
static PIN_Config SBP_configTable[]={
IOID_3 | PIN_GPIO_OUTPUT_DIS |PIN_INPUT_EN | PIN_PULLUP |PIN_HYSTERESIS, /* Button is active low */
PIN_TERMINATE
};
PIN_init(SBP_configTable);
#include <ti/drivers/pin/PINCC26XX.h>
static PIN_State sbpPins;
static PIN_Handle hSbpPins;
// Open pin structure for use
hSbpPins =PIN_open(&sbpPins,SBP_configTable);
// Register ISR
PIN_registerIntCb(hSbpPins,buttonHwiFxn);
// Configure interrupt
PIN_setConfig(hSbpPins,PIN_BM_IRQ,IOID_3|PIN_IRQ_BOTHEDGES);
// Enable wakeup
PIN_setConfig(hSbpPins,PINCC26XX_BM_WAKEUP,IOID_3|PINCC26XX_WAKEUP_NEGEDGE);
static void buttonHwiFxn(PIN_Handle hPin,PIN_Id pinId)
{
if (sem != NULL){
// set event in SBP task to process outside of hwi context
events |= SBP_BTN_EVT;
// Wake up the application.
Semaphore_post(sem);
}
}
if(events &SBP_BTN_EVT)
{
//clear event
events &= ~SBP_BTN_EVT;
//toggle LED1
//some codes for interrupt
}