소스 검색

🐛 STM32 ADC followup (#22798)

Tanguy Pruvot 3 년 전
부모
커밋
10fda222ea
No account linked to committer's email address
2개의 변경된 파일5개의 추가작업 그리고 5개의 파일을 삭제
  1. 4
    4
      Marlin/src/HAL/LPC1768/HAL.h
  2. 1
    1
      Marlin/src/HAL/STM32F1/HAL.cpp

+ 4
- 4
Marlin/src/HAL/LPC1768/HAL.h 파일 보기

@@ -156,17 +156,17 @@ int freeMemory();
156 156
 
157 157
 using FilteredADC = LPC176x::ADC<ADC_LOWPASS_K_VALUE, ADC_MEDIAN_FILTER_SIZE>;
158 158
 extern uint32_t HAL_adc_reading;
159
-[[gnu::always_inline]] inline void HAL_start_adc(const pin_t pin) {
159
+[[gnu::always_inline]] inline void HAL_adc_start_conversion(const pin_t pin) {
160 160
   HAL_adc_reading = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits
161 161
 }
162
-[[gnu::always_inline]] inline uint16_t HAL_read_adc() {
162
+[[gnu::always_inline]] inline uint16_t HAL_adc_get_result() {
163 163
   return HAL_adc_reading;
164 164
 }
165 165
 
166 166
 #define HAL_adc_init()
167 167
 #define HAL_ANALOG_SELECT(pin) FilteredADC::enable_channel(pin)
168
-#define HAL_START_ADC(pin)     HAL_start_adc(pin)
169
-#define HAL_READ_ADC()         HAL_read_adc()
168
+#define HAL_START_ADC(pin)     HAL_adc_start_conversion(pin)
169
+#define HAL_READ_ADC()         HAL_adc_get_result()
170 170
 #define HAL_ADC_READY()        (true)
171 171
 
172 172
 // Test whether the pin is valid

+ 1
- 1
Marlin/src/HAL/STM32F1/HAL.cpp 파일 보기

@@ -437,7 +437,7 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
437 437
       case POWER_MONITOR_VOLTAGE_PIN: pin_index = POWERMON_VOLTS; break;
438 438
     #endif
439 439
   }
440
-  HAL_adc_result = (HAL_adc_results[(int)pin_index] >> 2) & 0x3FF; // shift to get 10 bits only.
440
+  HAL_adc_result = HAL_adc_results[(int)pin_index] >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits
441 441
 }
442 442
 
443 443
 uint16_t HAL_adc_get_result() { return HAL_adc_result; }

Loading…
취소
저장