mirror of
https://github.com/Dasharo/zephyr.git
synced 2026-03-06 14:57:20 -08:00
drivers: adc: iadc_gecko: select proper bits from sample
Only 12-bit resolution is currently available in the driver, and each of the 16-bit samples store the actual data aligned to the left. A sample should be shifted 4 bits to the right to allow proper interpretation. Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
This commit is contained in:
committed by
Carles Cufí
parent
d42b2e0a9b
commit
48fc80fa79
@@ -20,6 +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);
|
||||
|
||||
struct adc_gecko_channel_config {
|
||||
IADC_CfgAnalogGain_t gain;
|
||||
@@ -231,7 +232,7 @@ static void adc_gecko_isr(void *arg)
|
||||
if (!err) {
|
||||
sample = IADC_readSingleResult(iadc);
|
||||
|
||||
*data->buffer++ = (uint16_t)sample.data;
|
||||
*data->buffer++ = GECKO_DATA_RES12BIT((uint16_t)sample.data);
|
||||
data->channels &= ~BIT(data->channel_id);
|
||||
|
||||
if (data->channels) {
|
||||
|
||||
Reference in New Issue
Block a user