Skip to content

Commit f7f8332

Browse files
committed
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 <[email protected]>
1 parent 92d2de8 commit f7f8332

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

ports/stm32/machine_adc.c

-2
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,10 @@ uint32_t adc_config_and_read_u16(ADC_TypeDef *adc, uint32_t channel, uint32_t sa
374374

375375
// Scale raw reading to 16 bit value using a Taylor expansion (for bits <= 16).
376376
uint32_t bits = adc_get_bits(adc);
377-
#if defined(STM32H7)
378377
if (bits < 8) {
379378
// For 6 and 7 bits
380379
return raw << (16 - bits) | raw << (16 - 2 * bits) | raw >> (3 * bits - 16);
381380
}
382-
#endif
383381
return raw << (16 - bits) | raw >> (2 * bits - 16);
384382
}
385383

0 commit comments

Comments
 (0)