This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/BOOSTXL-CC2650MA: Error while initializing GPIO inputs to trigger led

Part Number: BOOSTXL-CC2650MA
Other Parts Discussed in Thread: SYSBIOS

Tool/software: Code Composer Studio

I am using this pin_interrupt.c code but button pins are not initialized. Please help me to figure out what's wrong with the code

* ======== pinInterrupt.c ========
*/

/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>

/* TI-RTOS Header files */
#include <ti/drivers/PIN.h>
#include <ti/drivers/pin/PINCC26XX.h>

/* Example/Board Header files */
#include "Board.h"


/* Pin driver handles */
static PIN_Handle buttonPinHandle;
static PIN_Handle ledPinHandle;

/* Global memory storage for a PIN_Config table */
static PIN_State buttonPinState;
static PIN_State ledPinState;

#define Board_LED0 Board_RLED
#define Board_LED1 Board_GLED

#define Board_BUTTON0 PIN_ID(2)
#define Board_BUTTON1 PIN_ID(3)


/*

* Initial LED pin configuration table
* - LEDs Board_LED0 is on.
* - LEDs Board_LED1 is off.
*/
PIN_Config ledPinTable[] = {
Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
PIN_TERMINATE
};

/*
* Application button pin configuration table:
* - Buttons interrupts are configured to trigger on falling edge.
*/
PIN_Config buttonPinTable[] = {
Board_BUTTON0 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
Board_BUTTON1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
PIN_TERMINATE
};

/*
* ======== buttonCallbackFxn ========
* Pin interrupt Callback function board buttons configured in the pinTable.
* If Board_LED3 and Board_LED4 are defined, then we'll add them to the PIN
* callback function.
*/
void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
uint32_t currVal = 0;

/* Debounce logic, only toggle if the button is still pushed (low) */
CPUdelay(8000*50);
if (!PIN_getInputValue(pinId)) {
/* Toggle LED based on the button pressed */
switch (pinId) {
case Board_BUTTON0:
currVal = PIN_getOutputValue(Board_LED0);
PIN_setOutputValue(ledPinHandle, Board_LED0, !currVal);
break;

case Board_BUTTON1:
currVal = PIN_getOutputValue(Board_LED1);
PIN_setOutputValue(ledPinHandle, Board_LED1, !currVal);
break;

default:
/* Do nothing */
break;
}
}
}

/*
* ======== main ========
*/
int main(void)
{
/* Call board init functions */
Board_initGeneral();

/* Open LED pins */
ledPinHandle = PIN_open(&ledPinState, ledPinTable);
if(!ledPinHandle) {
System_abort("Error initializing board LED pins\n");
}

buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
if(!buttonPinHandle) {
System_abort("Error initializing button pins\n");
}

/* Setup callback for button pins */
if (PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn) != 0) {
System_abort("Error registering button callback function");
}

/* Start kernel. */
BIOS_start();

return (0);
}