12-bit ADC resolution for STM32 (#20519)

This commit is contained in:
LinFor 2020-12-22 03:30:03 +03:00 committed by Scott Lahteine
parent 231e5a5eed
commit 076f12e82d
3 changed files with 7 additions and 3 deletions

View File

@ -159,14 +159,14 @@ static inline int freeMemory() {
#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT)
inline void HAL_adc_init() {}
#define HAL_ADC_VREF 3.3
#define HAL_ADC_RESOLUTION 10
#define HAL_ADC_RESOLUTION ADC_RESOLUTION // 12
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_result
#define HAL_ADC_READY() true
inline void HAL_adc_init() { analogReadResolution(HAL_ADC_RESOLUTION); }
void HAL_adc_start_conversion(const uint8_t adc_pin);
uint16_t HAL_adc_get_result();

View File

@ -27,6 +27,8 @@
#define THERMISTOR_TABLE_SCALE (HAL_ADC_RANGE / _BV(THERMISTOR_TABLE_ADC_RESOLUTION))
#if ENABLED(HAL_ADC_FILTERED)
#define OVERSAMPLENR 1
#elif HAL_ADC_RESOLUTION > 10
#define OVERSAMPLENR (20 - HAL_ADC_RESOLUTION)
#else
#define OVERSAMPLENR 16
#endif

View File

@ -114,6 +114,8 @@ extern "C" {
#define NUM_ANALOG_INPUTS 7
#define NUM_ANALOG_FIRST 80
#define ADC_RESOLUTION 12
// PWM resolution
// #define PWM_RESOLUTION 12
#define PWM_FREQUENCY 20000 // >= 20 Khz => inaudible noise for fans