Hi everyone,
I'm using the Sensor Controller with a custom Simple BLE project. With my smartphone, I send a message to start several times the Sensor Controller between the connections events. The Sensor controller will blink a LED and alert the main CPU when over, the main function will wait the connections events to start the sensor.
It works around 60 times, but then everything stop and i'm unable to find the reason. Even the BLE communication crash.
The job of the sensor controller is described below, initialization and termination code are empty. The Sensor Controller is not driven by the RTC.
U16 x = 0; U16 n = 0; while(x < cfg.connInterval) { gpioSetOutput(cfg.pAuxioOLedCtrl[n]); fwDelayUs(1800, FW_DELAY_RANGE_2_MS); gpioClearOutput(cfg.pAuxioOLedCtrl[n]); fwDelayUs(200, FW_DELAY_RANGE_200_US); x = x + 4; } fwGenAlertInterrupt();
Functions used to init, start and stop the sensor controller :
void SensorController_init(void) { scifOsalRegisterCtrlReadyCallback(scCtrlReadyCallback); scifOsalRegisterTaskAlertCallback(scTaskAlertCallback); scifOsalInit(); scifInit(&scifDriverSetup); IntMasterEnable(); } SCIF_RESULT_T SensorController_stop(void) { SCIF_RESULT_T res; scifResetTaskStructs(BV(SCIF_LED_BLINKER_TASK_ID),BV(SCIF_STRUCT_OUTPUT)); res = scifStopTasksNbl(BV(SCIF_LED_BLINKER_TASK_ID)); return res; } SCIF_RESULT_T SensorController_start_once(uint16_t tck, uint32_t start) { SCIF_RESULT_T sys ; // Give SensorController interval time scifTaskData.ledBlinker.cfg.connInterval = (uint16_t)tck; sys = scifStartTasksNbl(BV(SCIF_LED_BLINKER_TASK_ID)); // Init - execute - terminate return sys; }
When the smartphone will command the system to start, I register to the HCI connection event :
HCI_EXT_ConnEventNoticeCmd(selfEntity,PERI_CON_EVT_COMPLETE_EVT);
I will wait on the connection event and start the sensor controller
if (ICall_fetchServiceMsg(&src, &dest, (void **)&pMsg) == ICALL_ERRNO_SUCCESS) { if ((src == ICALL_SERVICE_CLASS_BLE) && (dest == selfEntity)) { ICall_Event *pEvent = (ICall_Event*)pMsg; if(pEvent->signature == 0xffff) { pEvent->signature &= ~0xffff; if(pEvent->event_flag == PERI_CON_EVT_COMPLETE_EVT) // Connection event started { pEvent->event_flag &= ~PERI_CON_EVT_COMPLETE_EVT; // Do x steps SensorController_start_once(TCK, start); LCD_WRITE_STRING("Started",LCD_PAGE4); while(scifWaitOnNbl(0) != SCIF_SUCCESS); if(Semaphore_pend(Semaphore_handle(&semScTaskAlert),BIOS_NO_WAIT)) { scifClearAlertIntSource(); scifAckAlertEvents(); } SensorController_stop(); while(scifWaitOnNbl(0) != SCIF_SUCCESS); } } Peri_Peripheral_processStackMsg((ICall_Hdr *)pMsg); // Process inter-task message }
The system will turn around 64 times, always (even with a task_sleep between) before crashing. And all functions return SCIF_SUCCESS.
If I send another BLE order, write orders on android will not respond and the system will start one - two times the sensor before complete freeze.
Any help is welcome.
Have a nice day
Sebastien