Skip to content
Snippets Groups Projects
Commit 88ae77eb authored by Adrian Schneider's avatar Adrian Schneider
Browse files

chore(light_sensor) make error codes negative, use more precise error number

parent f3cf813e
Branches
No related tags found
No related merge requests found
Pipeline #1329 passed
...@@ -15,7 +15,7 @@ static TaskHandle_t poll_task; ...@@ -15,7 +15,7 @@ static TaskHandle_t poll_task;
{ {
const sys_cfg_adc_t sys_adc_cfg = NULL; /* No system specific configuration needed. */ const sys_cfg_adc_t sys_adc_cfg = NULL; /* No system specific configuration needed. */
if (ADC_Init(0x9, &sys_adc_cfg) != E_NO_ERROR) { if (ADC_Init(0x9, &sys_adc_cfg) != E_NO_ERROR) {
return EINVAL; return -EINVAL;
} }
GPIO_Config(&gpio_cfg_adc7); GPIO_Config(&gpio_cfg_adc7);
return 0; return 0;
...@@ -71,7 +71,7 @@ int epic_light_sensor_get(uint16_t* value) ...@@ -71,7 +71,7 @@ int epic_light_sensor_get(uint16_t* value)
{ {
if (!poll_task) if (!poll_task)
{ {
return EINVAL; return -ENODATA;
} }
*value = last_value; *value = last_value;
return 0; return 0;
......
...@@ -14,7 +14,7 @@ STATIC mp_obj_t mp_light_sensor_get_reading() ...@@ -14,7 +14,7 @@ STATIC mp_obj_t mp_light_sensor_get_reading()
{ {
uint16_t last; uint16_t last;
int status = epic_light_sensor_get(&last); int status = epic_light_sensor_get(&last);
if (status == EINVAL) if (status == -ENODATA)
{ {
mp_raise_ValueError("sensor not running"); mp_raise_ValueError("sensor not running");
return mp_const_none; return mp_const_none;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment