From 00e6e90648012ca0b954139f867a9a0201319209 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 25 Dec 2021 22:10:47 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20adc=5Fstart=20for=20AVR,?= =?UTF-8?q?=20native?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #23295 --- Marlin/src/HAL/AVR/HAL.h | 10 ++++++---- Marlin/src/HAL/LINUX/HAL.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index 682374b4ac..3dade7fa15 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -229,12 +229,14 @@ public: } // Begin ADC sampling on the given channel - static inline void adc_start(const pin_t ch) { + static inline void adc_start(const uint8_t ch) { #ifdef MUX5 - if (ch > 7) { ADCSRB = _BV(MUX5); return; } + ADCSRB = ch > 7 ? _BV(MUX5) : 0; + #else + ADCSRB = 0; #endif - ADCSRB = 0; - ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC); + ADMUX = _BV(REFS0) | (ch & 0x07); + SBI(ADCSRA, ADSC); } // Is the ADC ready for reading? diff --git a/Marlin/src/HAL/LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h index a2a9692cbd..104c47ec61 100644 --- a/Marlin/src/HAL/LINUX/HAL.h +++ b/Marlin/src/HAL/LINUX/HAL.h @@ -140,7 +140,7 @@ public: static inline void adc_enable(const uint8_t) {} // Begin ADC sampling on the given channel - static inline void adc_start(const pin_t ch) { active_ch = ch; } + static inline void adc_start(const uint8_t ch) { active_ch = ch; } // Is the ADC ready for reading? static inline bool adc_ready() { return true; }