From 92af172159d5b0e0c32e31b0f1aac3bf03341314 Mon Sep 17 00:00:00 2001 From: Paulo Santos Date: Tue, 9 Jan 2024 13:58:06 -0300 Subject: [PATCH] drivers: adc: iadc_gecko: fix sample bits reading The current driver initializes the IADC with the default configuration (IADC_INITSINGLE_DEFAULT), which aligns the data to the right. To correctly read the 12-bit sample, it should be masked from the right instead. Signed-off-by: Paulo Santos --- drivers/adc/iadc_gecko.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/adc/iadc_gecko.c b/drivers/adc/iadc_gecko.c index 1317a4e472..d9dc542a5b 100644 --- a/drivers/adc/iadc_gecko.c +++ b/drivers/adc/iadc_gecko.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(iadc_gecko, CONFIG_ADC_LOG_LEVEL); /* Number of channels available. */ #define GECKO_CHANNEL_COUNT 16 #define GECKO_INTERNAL_REFERENCE_mV 1210 -#define GECKO_DATA_RES12BIT(DATA) ((DATA & 0xFFF0) >> 4); +#define GECKO_DATA_RES12BIT(DATA) ((DATA) & 0x0FFF) struct adc_gecko_channel_config { IADC_CfgAnalogGain_t gain;