From d80f362a2be688098b9fb3c3cbcbe1c32b31eb92 Mon Sep 17 00:00:00 2001 From: Thanos Tsakiris Date: Wed, 8 Mar 2017 15:55:28 +0200 Subject: [PATCH 1/2] Adjust CC26xx/CC13xx ADC reading for gain and offset --- cpu/cc26xx-cc13xx/dev/adc-sensor.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cpu/cc26xx-cc13xx/dev/adc-sensor.c b/cpu/cc26xx-cc13xx/dev/adc-sensor.c index 3ccf90e6d..1bf6c291e 100644 --- a/cpu/cc26xx-cc13xx/dev/adc-sensor.c +++ b/cpu/cc26xx-cc13xx/dev/adc-sensor.c @@ -107,7 +107,7 @@ static int value(int type) { if(type == ADC_SENSOR_VALUE) { - int val; + int val, adj_val, adj_mv; if(!is_active) { puts("ADC not active"); @@ -119,10 +119,15 @@ value(int type) ti_lib_aux_adc_gen_manual_trigger(); val = ti_lib_aux_adc_read_fifo(); - + adj_val = ti_lib_aux_adc_adjust_value_for_gain_and_offset( + val, + ti_lib_aux_adc_get_adjustment_gain(AUXADC_REF_FIXED), + ti_lib_aux_adc_get_adjustment_offset(AUXADC_REF_FIXED) ); + adj_mv = ti_lib_aux_adc_value_to_microvolts(AUXADC_FIXED_REF_VOLTAGE_NORMAL, adj_val); + ti_lib_aux_adc_disable(); - return val; + return adj_mv; } return 0; From dbcac67aab2c90bf24602a60208d8566e00aea05 Mon Sep 17 00:00:00 2001 From: Thanos Tsakiris Date: Wed, 8 Mar 2017 17:09:53 +0200 Subject: [PATCH 2/2] Normalize code style with uncrustify --- cpu/cc26xx-cc13xx/dev/adc-sensor.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cpu/cc26xx-cc13xx/dev/adc-sensor.c b/cpu/cc26xx-cc13xx/dev/adc-sensor.c index 1bf6c291e..1f736bb53 100644 --- a/cpu/cc26xx-cc13xx/dev/adc-sensor.c +++ b/cpu/cc26xx-cc13xx/dev/adc-sensor.c @@ -120,11 +120,10 @@ value(int type) ti_lib_aux_adc_gen_manual_trigger(); val = ti_lib_aux_adc_read_fifo(); adj_val = ti_lib_aux_adc_adjust_value_for_gain_and_offset( - val, - ti_lib_aux_adc_get_adjustment_gain(AUXADC_REF_FIXED), - ti_lib_aux_adc_get_adjustment_offset(AUXADC_REF_FIXED) ); + val, + ti_lib_aux_adc_get_adjustment_gain(AUXADC_REF_FIXED), + ti_lib_aux_adc_get_adjustment_offset(AUXADC_REF_FIXED)); adj_mv = ti_lib_aux_adc_value_to_microvolts(AUXADC_FIXED_REF_VOLTAGE_NORMAL, adj_val); - ti_lib_aux_adc_disable(); return adj_mv;