Sfoglia il codice sorgente

🐛 Fix adc_start for AVR, native

Followup to #23295
Scott Lahteine 3 anni fa
parent
commit
00e6e90648
2 ha cambiato i file con 7 aggiunte e 5 eliminazioni
  1. 6
    4
      Marlin/src/HAL/AVR/HAL.h
  2. 1
    1
      Marlin/src/HAL/LINUX/HAL.h

+ 6
- 4
Marlin/src/HAL/AVR/HAL.h Vedi File

@@ -229,12 +229,14 @@ public:
229 229
   }
230 230
 
231 231
   // Begin ADC sampling on the given channel
232
-  static inline void adc_start(const pin_t ch) {
232
+  static inline void adc_start(const uint8_t ch) {
233 233
     #ifdef MUX5
234
-      if (ch > 7) { ADCSRB = _BV(MUX5); return; }
234
+      ADCSRB = ch > 7 ? _BV(MUX5) : 0;
235
+    #else
236
+      ADCSRB = 0;
235 237
     #endif
236
-    ADCSRB = 0;
237
-    ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC);
238
+    ADMUX = _BV(REFS0) | (ch & 0x07);
239
+    SBI(ADCSRA, ADSC);
238 240
   }
239 241
 
240 242
   // Is the ADC ready for reading?

+ 1
- 1
Marlin/src/HAL/LINUX/HAL.h Vedi File

@@ -140,7 +140,7 @@ public:
140 140
   static inline void adc_enable(const uint8_t) {}
141 141
 
142 142
   // Begin ADC sampling on the given channel
143
-  static inline void adc_start(const pin_t ch) { active_ch = ch; }
143
+  static inline void adc_start(const uint8_t ch) { active_ch = ch; }
144 144
 
145 145
   // Is the ADC ready for reading?
146 146
   static inline bool adc_ready() { return true; }

Loading…
Annulla
Salva