avr: Clear the ADCSRA/ADCSRB registers on ADC init

When initializing the ADC, explicitly clear the registers (instead of
logically or'ing them with their previous values).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-01-07 22:11:40 -05:00
parent 83e9e92b9a
commit f6cd51bfb7
1 changed files with 2 additions and 2 deletions

View File

@ -280,7 +280,7 @@ gpio_adc_setup(uint8_t pin)
}
// Enable ADC
ADCSRA |= (1<<ADPS0)|(1<<ADPS1)|(1<<ADPS2)|(1<<ADEN);
ADCSRA = (1<<ADPS0)|(1<<ADPS1)|(1<<ADPS2)|(1<<ADEN);
// Disable digital input for this pin
#ifdef DIDR2
@ -316,7 +316,7 @@ gpio_adc_sample(struct gpio_adc g)
#if defined(ADCSRB) && defined(MUX5)
// the MUX5 bit of ADCSRB selects whether we're reading from channels
// 0 to 7 (MUX5 low) or 8 to 15 (MUX5 high).
ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((g.chan >> 3) & 0x01) << MUX5);
ADCSRB = ((g.chan >> 3) & 0x01) << MUX5;
#endif
ADMUX = ADMUX_DEFAULT | (g.chan & 0x07);