Good morning everyone,
I'm currently trying to use at best the Sensor controller on the CC2650, with smartRF06 and Code Composer. I have integrated the Sensor Controller Interface (SCIF) with the Simple Peripheral project, and I'm able to measure the ADC level on the Light sensor.
What I'm trying to do is simple : Init the sensor controller, begin the measurements, wait for result, disable the sensor controller.
Init of sensor :
void Light_Sensor_init(void) { // Initialize the Sensor Controller scifOsalInit(); scifOsalRegisterCtrlReadyCallback(scCtrlReadyCallback); scifOsalRegisterTaskAlertCallback(scTaskAlertCallback); scifInit(&scifDriverSetup); }
Starting the sensor ; As the application may ensure that the start ticks are not in the past, i read the rtc and add some time.
SCIF_RESULT_T Light_Sensor_start_once(uint32_t tck) { SCIF_RESULT_T sys ; uint32_t RTC_start = 0 ; RTC_start = AONRTCCurrentCompareValueGet(); RTC_start |= 0x00010000; scifStartRtcTicks(RTC_start, tck); scifTaskData.analogLightSensor.cfg.hysteresis = 16; scifTaskData.analogLightSensor.cfg.pBinThresholds[0] = 0; scifTaskData.analogLightSensor.cfg.pBinThresholds[1] = 400; scifTaskData.analogLightSensor.cfg.pBinThresholds[2] = 600; scifTaskData.analogLightSensor.cfg.pBinThresholds[3] = 800; scifTaskData.analogLightSensor.cfg.pBinThresholds[4] = 1000; scifTaskData.analogLightSensor.cfg.pBinThresholds[5] = 4095; sys = scifStartTasksNbl(BV(SCIF_ANALOG_LIGHT_SENSOR_TASK_ID)); return sys; }
Wait for results :
light = Light_Sensor_start_once(TCK_SHORT); if(light == SCIF_SUCCESS) { if(Semaphore_pend(Semaphore_handle(&semScTaskAlert),BIOS_WAIT_FOREVER)) { scifClearAlertIntSource(); uint16_t bin = scifTaskData.analogLightSensor.output.bin; Light_Sensor_adc_value = (uint8_t) (bin&0xFF) ; SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, sizeof(uint8_t), &Light_Sensor_adc_value); scifAckAlertEvents(); } } Light_Sensor_stop();
And finally the function that should top the sensor controller :
void Light_Sensor_stop(void) { scifStopRtcTicks(); scifStopTasksNbl(BV(SCIF_ANALOG_LIGHT_SENSOR_TASK_ID)); scifResetTaskStructs(BV(SCIF_ANALOG_LIGHT_SENSOR_TASK_ID),BV(SCIF_ANALOG_LIGHT_SENSOR_STRUCT)); }
The system start and do not see an alert (event with an hysteresis of 0), next time i try to start the sensor controller it crash completely.
Thanks in advance if you have an idea how to stop and start the sensor controller in the right way
Have a nice day
EDIT :
The solution have been found and is posted .. the init function has to be called during global initialisation... then starting and stopping the sensor controller is quite easy.