Skip to content
Snippets Groups Projects
Commit 18cea8d7 authored by schneider's avatar schneider
Browse files

fix(light_sensor): Use work queue

parent fe1356cb
No related branches found
No related tags found
No related merge requests found
Pipeline #4960 passed
...@@ -38,17 +38,14 @@ uint16_t epic_light_sensor_read() ...@@ -38,17 +38,14 @@ uint16_t epic_light_sensor_read()
return last_value; return last_value;
} }
static void readAdcCallback() static void workpoll(void *data)
{ {
if (hwlock_acquire_nonblock(HWLOCK_ADC) != 0) { epic_light_sensor_read();
/* Can't do much about this here ... Retry next time */
return;
} }
ADC_StartConvert(ADC_CH_7, 0, 0); static void poll(TimerHandle_t xTimer)
ADC_GetData(&last_value); {
workqueue_schedule(workpoll, NULL);
hwlock_release(HWLOCK_ADC);
} }
int epic_light_sensor_run() int epic_light_sensor_run()
...@@ -65,7 +62,7 @@ int epic_light_sensor_run() ...@@ -65,7 +62,7 @@ int epic_light_sensor_run()
READ_FREQ, READ_FREQ,
pdTRUE, pdTRUE,
NULL, NULL,
readAdcCallback, poll,
&poll_timer_buffer &poll_timer_buffer
); );
// since &poll_timer_buffer is not NULL, xTimerCreateStatic should allways succeed, so // since &poll_timer_buffer is not NULL, xTimerCreateStatic should allways succeed, so
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment