aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/avr/analog.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/avr/analog.c b/drivers/avr/analog.c
index 9b8397b93..8d299ffdb 100644
--- a/drivers/avr/analog.c
+++ b/drivers/avr/analog.c
@@ -97,10 +97,11 @@ uint8_t pinToMux(pin_t pin) {
#endif
// clang-format on
}
+ return 0;
}
int16_t adc_read(uint8_t mux) {
- uint8_t low;
+ uint16_t low;
// Enable ADC and configure prescaler
ADCSRA = _BV(ADEN) | ADC_PRESCALER;
@@ -128,5 +129,10 @@ int16_t adc_read(uint8_t mux) {
// Must read LSB first
low = ADCL;
// Must read MSB only once!
- return (ADCH << 8) | low;
+ low |= (ADCH << 8);
+
+ // turn off the ADC
+ ADCSRA &= ~(1 << ADEN);
+
+ return low;
}