From ceaf1e4a83638a320032b4710e74763a85e0d49e Mon Sep 17 00:00:00 2001 From: schneider <schneider@blinkenlichts.net> Date: Tue, 28 Apr 2020 20:28:12 +0200 Subject: [PATCH] refact(light_sensor): Use new style HW locks --- epicardium/modules/light_sensor.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/epicardium/modules/light_sensor.c b/epicardium/modules/light_sensor.c index a0f997ac1..ea8d74c36 100644 --- a/epicardium/modules/light_sensor.c +++ b/epicardium/modules/light_sensor.c @@ -29,9 +29,7 @@ static int light_sensor_init() uint16_t epic_light_sensor_read() { - if (hwlock_acquire_timeout(HWLOCK_ADC, portMAX_DELAY) != 0) { - return 0; - } + hwlock_acquire(HWLOCK_ADC); ADC_StartConvert(ADC_CH_7, 0, 0); ADC_GetData(&last_value); @@ -42,7 +40,7 @@ uint16_t epic_light_sensor_read() static void readAdcCallback() { - if (hwlock_acquire_timeout(HWLOCK_ADC, 0) != 0) { + if (hwlock_acquire_nonblock(HWLOCK_ADC) != 0) { /* Can't do much about this here ... Retry next time */ return; } @@ -57,9 +55,7 @@ int epic_light_sensor_run() { int ret = 0; - if (hwlock_acquire_timeout(HWLOCK_ADC, portMAX_DELAY) != 0) { - return -EBUSY; - } + hwlock_acquire(HWLOCK_ADC); light_sensor_init(); -- GitLab