diff options
Diffstat (limited to 'software/hhd70dongle/util.c')
-rw-r--r-- | software/hhd70dongle/util.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/software/hhd70dongle/util.c b/software/hhd70dongle/util.c index 2c358fa..56fe575 100644 --- a/software/hhd70dongle/util.c +++ b/software/hhd70dongle/util.c @@ -70,19 +70,26 @@ void reset(void) #endif } +//not switchin off adc produces slightly besser results +void adc_on(void) +{ + ADCSRA = (1<<ADEN) | 0b00000111; // enable ADC, Prescaler 1:128 +} + +void adc_off(void) +{ + ADCSRA &= ~(1<<ADEN); // disable ADC -> save power +} + + uint8_t adc_read(uint8_t mux) { ADCSRB = (mux & 0x20); // select input ADMUX = 0b11100000 | (mux & 0x1F); // select input cont'd // select internal 2.56V reference, // result is left justified - ADCSRA = (1<<ADEN) | 0b00000111; // enable ADC, Prescaler 1:128 - ADCSRA |= (1<<ADSC); // start the conversion while (ADCSRA & (1<<ADSC)) ; // wait for result - - ADCSRA &= ~(1<<ADEN); // disable ADC -> save power - return ADCH; } |