Skip to content

Commit

Permalink
🐛 Fix adc_start for AVR, native
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Dec 26, 2021
1 parent 555c749 commit 00e6e90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions Marlin/src/HAL/AVR/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@ class MarlinHAL {
}

// 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?
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LINUX/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class MarlinHAL {
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; }
Expand Down

0 comments on commit 00e6e90

Please sign in to comment.