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.
Here are the steps to merge a Sensor Controller (SC) example into the simple_peripheral example (CC2640R2F / BLE3):
The steps could be reused for all the devices having a Sensor Controller.
Before we start:
Here is the step by step guide:
static void SimplePeripheral_taskFxn(UArg a0, UArg a1) { // Initialize application SimplePeripheral_init(); //**************************************// // This code for SC initialization // //**************************************// // Initialize and start the Sensor Controller scifOsalInit(); scifOsalRegisterCtrlReadyCallback(scCtrlReadyCallback); scifOsalRegisterTaskAlertCallback(scTaskAlertCallback); scifInit(&scifDriverSetup); scifStartRtcTicksNow(0x00010000 / 10); scifStartTasksNbl(BV(SCIF_LED_BLINKER_TASK_ID)); //*************************************// // This code for GLED initialization // //************************************// // Enable LED pins hLedPins = PIN_open(&ledPinState, pLedPinTable); // Application main loop for (;;) { uint32_t events; // Waits for an event to be posted associated with the calling thread. // Note that an event associated with a thread is posted when a // message is queued to the message receive queue of the thread events = Event_pend(syncEvent, Event_Id_NONE, SBP_ALL_EVENTS, ICALL_TIMEOUT_FOREVER);
#include "scif.h" PIN_Config pLedPinTable[] = { Board_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, PIN_TERMINATE }; PIN_State ledPinState; PIN_Handle hLedPins; void scCtrlReadyCallback(void) { } // scCtrlReadyCallback void scTaskAlertCallback(void) { SimplePeripheral_enqueueMsg(SBP_SC_ALERT, NULL, NULL); } // scTaskAlertCallback
// Application events #define SBP_STATE_CHANGE_EVT 0x0001 #define SBP_CHAR_CHANGE_EVT 0x0002 #define SBP_PAIRING_STATE_EVT 0x0004 #define SBP_PASSCODE_NEEDED_EVT 0x0008 #define SBP_CONN_EVT 0x0010 #define SBP_SC_ALERT 0x0099 // This one get added
Here is the code to handle the SBP_SC_ALERT events (added in SimplePeripheral_processAppMsg):
static void SimplePeripheral_processAppMsg(sbpEvt_t *pMsg) { switch (pMsg->hdr.event) { // ... case SBP_CONN_EVT: { SimplePeripheral_processConnEvt((Gap_ConnEventRpt_t *)(pMsg->pData)); ICall_free(pMsg->pData); break; } //*********************// // This code is added // //*********************// case SBP_SC_ALERT: { // Clear the ALERT interrupt source scifClearAlertIntSource(); // If the LED blinker task has not been stopped ... if (scifGetActiveTaskIds() & BV(SCIF_LED_BLINKER_TASK_ID)) { // Indicate value of the output counter variable on the green LED PIN_setOutputValue(hLedPins, Board_GLED, (scifTaskData.ledBlinker.output.counter & 0x0001) != 0); } // Acknowledge the ALERT event scifAckAlertEvents(); break; } //*********************// // End of added code // //*********************// default: // Do nothing. break; } }