From 18cea8d7d5967260aa61a7d0a8e576a5ca82c41a Mon Sep 17 00:00:00 2001 From: schneider <schneider@blinkenlichts.net> Date: Sun, 6 Dec 2020 23:50:51 +0100 Subject: [PATCH] fix(light_sensor): Use work queue --- epicardium/modules/light_sensor.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/epicardium/modules/light_sensor.c b/epicardium/modules/light_sensor.c index ea8d74c36..e7ab899d2 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 -- GitLab