Other Parts Discussed in Thread: LAUNCHXL-CC1310
Tool/software: TI-RTOS
I need some help with applying the example provided in chapter 8 "Peripherals and Drivers" in Embedded developer's Guide.
I don't know how to apply steps 2 and 3. (where to add these codes?)
The Example provided in the Embedded developer's Guide:-
--------------------------------------------------------------------------------------------------------------------------
The following sensor-specific functions, ssf.c, and code modifications are required:
1. Include PIN driver files:
#include <ti/drivers/pin/PIN.h>
2. Declare the pin configuration table and pin state and handle variables to be used by the
sensor_cc13x0lp task:
static PIN_Config SSF_configTable[] =
{
Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_BUTTON0 | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS,
PIN_TERMINATE
};
static PIN_State ssfPins;
static PIN_Handle hSsfPins;
3. Declare the ISR to be performed in the hwi context. This sets an event in the application task and
wakes it up, to minimize processing in the hwi context.
static void buttonHwiFxn (PIN_Handle hPin, PIN_Id pinId)
{
// set event in SSF task to process outside of hwi context
events |= SSF_BTN_EVT;
// Wake up the application.
Semaphore_post(sem);
}
4. Define the event and related processing (in Sensor_process()) to handle the event from Step 3.
#define SSF_BTN_EVT 0x0001
if (events & SSF_BTN_EVT)
{
events &= ~SSF_BTN_EVT; //clear event
//toggle LED0
if (LED_value)
{
PIN_setOutputValue(hSsfPins, Board_LED0, LED_value--);
}
else
{
PIN_setOutputValue(hSsfPins, Board_LED0, LED_value++);
}
}
5. In Sensor_init(), open the pins for use and configure the interrupt:
// Open pin structure for use hSsfPins = PIN_open(&ssfPins, SSF_configTable); // Register ISR PIN_registerIntCb(hSsfPins, buttonHwiFxn); // Configure interrupt PIN_setConfig(hSsfPins, PIN_BM_IRQ, Board_BUTTON0 | PIN_IRQ_NEGEDGE); // Enable wakeup PIN_setConfig(hSsfPins, PINCC26XX_BM_WAKEUP, Board_BUTTON0|PINCC26XX_WAKEUP_NEGEDGE);
6. Compile, download, and run. Pushing the Up button on the LaunchPad toggles the red LED. There is
no debouncing implemented here.