Browse Source

🐛 STM32 ADC Resolution = 12 bit (or ADC_RESOLUTION) (#22789)

Steven Haigh 3 years ago
parent
commit
d7e597f3df
No account linked to committer's email address
3 changed files with 12 additions and 3 deletions
  1. 6
    1
      Marlin/src/HAL/STM32/HAL.h
  2. 6
    1
      Marlin/src/HAL/STM32F1/HAL.h
  3. 0
    1
      ini/stm32-common.ini

+ 6
- 1
Marlin/src/HAL/STM32/HAL.h View File

183
 
183
 
184
 #define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT)
184
 #define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT)
185
 
185
 
186
+#ifdef ADC_RESOLUTION
187
+  #define HAL_ADC_RESOLUTION ADC_RESOLUTION
188
+#else
189
+  #define HAL_ADC_RESOLUTION 12
190
+#endif
191
+
186
 #define HAL_ADC_VREF         3.3
192
 #define HAL_ADC_VREF         3.3
187
-#define HAL_ADC_RESOLUTION  ADC_RESOLUTION // 12
188
 #define HAL_START_ADC(pin)  HAL_adc_start_conversion(pin)
193
 #define HAL_START_ADC(pin)  HAL_adc_start_conversion(pin)
189
 #define HAL_READ_ADC()      HAL_adc_result
194
 #define HAL_READ_ADC()      HAL_adc_result
190
 #define HAL_ADC_READY()     true
195
 #define HAL_ADC_READY()     true

+ 6
- 1
Marlin/src/HAL/STM32F1/HAL.h View File

237
 
237
 
238
 void HAL_adc_init();
238
 void HAL_adc_init();
239
 
239
 
240
+#ifdef ADC_RESOLUTION
241
+  #define HAL_ADC_RESOLUTION ADC_RESOLUTION
242
+#else
243
+  #define HAL_ADC_RESOLUTION 12
244
+#endif
245
+
240
 #define HAL_ADC_VREF         3.3
246
 #define HAL_ADC_VREF         3.3
241
-#define HAL_ADC_RESOLUTION  10
242
 #define HAL_START_ADC(pin)  HAL_adc_start_conversion(pin)
247
 #define HAL_START_ADC(pin)  HAL_adc_start_conversion(pin)
243
 #define HAL_READ_ADC()      HAL_adc_result
248
 #define HAL_READ_ADC()      HAL_adc_result
244
 #define HAL_ADC_READY()     true
249
 #define HAL_ADC_READY()     true

+ 0
- 1
ini/stm32-common.ini View File

16
                    -std=gnu++14 -DHAL_STM32
16
                    -std=gnu++14 -DHAL_STM32
17
                    -DUSBCON -DUSBD_USE_CDC
17
                    -DUSBCON -DUSBD_USE_CDC
18
                    -DTIM_IRQ_PRIO=13
18
                    -DTIM_IRQ_PRIO=13
19
-                   -DADC_RESOLUTION=12
20
 build_unflags    = -std=gnu++11
19
 build_unflags    = -std=gnu++11
21
 src_filter       = ${common.default_src_filter} +<src/HAL/STM32> +<src/HAL/shared/backtrace>
20
 src_filter       = ${common.default_src_filter} +<src/HAL/STM32> +<src/HAL/shared/backtrace>
22
 extra_scripts    = ${common.extra_scripts}
21
 extra_scripts    = ${common.extra_scripts}

Loading…
Cancel
Save