diff --git a/epicardium/modules/light_sensor.c b/epicardium/modules/light_sensor.c index ea8d74c36c92e381dd8239a2bd9b02617fd92b6a..e7ab899d25232a9b2f1fed665991a9d04568594d 100644 --- a/epicardium/modules/light_sensor.c +++ b/epicardium/modules/light_sensor.c @@ -38,17 +38,14 @@ uint16_t epic_light_sensor_read() return last_value; } -static void readAdcCallback() +static void workpoll(void *data) { - if (hwlock_acquire_nonblock(HWLOCK_ADC) != 0) { - /* Can't do much about this here ... Retry next time */ - return; - } - - ADC_StartConvert(ADC_CH_7, 0, 0); - ADC_GetData(&last_value); + epic_light_sensor_read(); +} - hwlock_release(HWLOCK_ADC); +static void poll(TimerHandle_t xTimer) +{ + workqueue_schedule(workpoll, NULL); } int epic_light_sensor_run() @@ -65,7 +62,7 @@ int epic_light_sensor_run() READ_FREQ, pdTRUE, NULL, - readAdcCallback, + poll, &poll_timer_buffer ); // since &poll_timer_buffer is not NULL, xTimerCreateStatic should allways succeed, so