Other Parts Discussed in Thread: CC1350
Tool/software: Code Composer Studio
Hello Team,
I have make a task which can work with simple peripheral example but its not working please help me where I am wrong. In this task my aim to work on GPIO interrput and blink LED. Source and header files are below.
Source (.c ) file:-
#include "Board.h" #include <ti/sysbios/knl/Semaphore.h> #include <ti/sysbios/knl/Task.h> #include <ti/sysbios/knl/Clock.h> #include <ti/sysbios/family/arm/m3/Hwi.h> #include <ti/drivers/Power.h> #include <ti/sysbios/BIOS.h> #include <ti/drivers/power/PowerCC26XX.h> #include <ti/drivers/PIN/PINCC26XX.h> #include <ti/drivers/UART.h> #include <xdc/std.h> #include <xdc/runtime/System.h> #include <ti/sysbios/knl/Event.h> #include <driverlib/aux_wuc.h> #include <inc/hw_aux_evctl.h> #include "util.h" #include "hci_tl.h" #include "gatt.h" #include "linkdb.h" #include "gapgattserver.h" #include "gattservapp.h" #include "devinfoservice.h" #include "simple_gatt_profile.h" #include "copy.h" /* TI-RTOS Header files */ #include <ti/drivers/PIN.h> /**********************Macros**********************************/ #define TASK_STACK_SIZE 512 #define TASK_PRI 2 /**************************************************************/ /***********************Global variables****************************/ //copyParams params; uint8_t Count = 0; /*Clock Variables*/ Clock_Struct clk0Struct; Clock_Handle clk2Handle; // Clock instances for internal periodic events. static Clock_Struct periodicClock; char taskStack[TASK_STACK_SIZE]; Task_Struct taskStruct; /* 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; 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 }; /****************************************************************/ 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; } } } void copy_createTask(void) { //Initialize task Task_Params params; Task_Params_init(¶ms); params.priority = TASK_PRI; params.stackSize = TASK_STACK_SIZE; params.stack = taskStack; Task_construct(&taskStruct, copytaskFxn, ¶ms, NULL); } void copytaskFxn(UArg a0, UArg a1) { //***********************clock**************************** /* Construct BIOS Objects */ Clock_Params clkParams; /* Call driver init functions */ // Board_initGeneral(); Clock_Params_init(&clkParams); clkParams.period = 1000000/Clock_tickPeriod; clkParams.startFlag = TRUE; /* Construct a periodic Clock Instance */ Clock_construct(&clk0Struct, (Clock_FuncPtr)copyIsr, 50000/Clock_tickPeriod, &clkParams); clkParams.period = 1000000/Clock_tickPeriod; clkParams.startFlag = FALSE; //************************************************************** } void copyIsr(void) { 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"); } if (PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn) != 0) { System_abort("Error registering button callback function"); } }
Header file:-