diff options
author | Damien George <damien@micropython.org> | 2023-06-15 10:58:53 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-06-15 11:02:55 +1000 |
commit | f7f8332ddf877c15f89c525fbfb34f5ff9f8f453 (patch) | |
tree | c0b22bd2d65e46dd00682cc36a54d1f85e7608ee | |
parent | 92d2de82e29fb27d329417a76f0dc95b5b29e9b1 (diff) | |
download | micropython-f7f8332ddf877c15f89c525fbfb34f5ff9f8f453.tar.gz micropython-f7f8332ddf877c15f89c525fbfb34f5ff9f8f453.zip |
stm32/machine_adc: Handle ADC resolution less than 8 bits on all MCUs.
All MCUs can have 6-bit resolution; see adc_cr_to_bits_table.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r-- | ports/stm32/machine_adc.c | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/ports/stm32/machine_adc.c b/ports/stm32/machine_adc.c index 34319e9753..f68ed0ec84 100644 --- a/ports/stm32/machine_adc.c +++ b/ports/stm32/machine_adc.c @@ -374,12 +374,10 @@ uint32_t adc_config_and_read_u16(ADC_TypeDef *adc, uint32_t channel, uint32_t sa // Scale raw reading to 16 bit value using a Taylor expansion (for bits <= 16). uint32_t bits = adc_get_bits(adc); - #if defined(STM32H7) if (bits < 8) { // For 6 and 7 bits return raw << (16 - bits) | raw << (16 - 2 * bits) | raw >> (3 * bits - 16); } - #endif return raw << (16 - bits) | raw >> (2 * bits - 16); } |