summaryrefslogtreecommitdiff
path: root/keyboard
diff options
context:
space:
mode:
authortmk <hasu@tmk-kbd.com>2014-12-03 02:08:27 +0900
committertmk <hasu@tmk-kbd.com>2015-01-15 17:08:48 +0900
commit25aee431bd83b46d694293c85a939d476943a5aa (patch)
tree8565380a9b24a5e13f3697821b3cdbf992266159 /keyboard
parent825be9d121a9c698bf60bbdc384f2eeaf66f60d0 (diff)
Clean ADC code of battery_voltage()
Diffstat (limited to 'keyboard')
-rw-r--r--keyboard/hhkb_rn42/rn42/battery.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/keyboard/hhkb_rn42/rn42/battery.c b/keyboard/hhkb_rn42/rn42/battery.c
index 720d63bebb..3ecde52234 100644
--- a/keyboard/hhkb_rn42/rn42/battery.c
+++ b/keyboard/hhkb_rn42/rn42/battery.c
@@ -20,7 +20,6 @@ void battery_init(void)
// Ref:2.56V band-gap, Input:ADC0(PF0), Prescale:128(16MHz/128=125KHz)
ADMUX = (1<<REFS1) | (1<<REFS0);
ADCSRA = (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);
- ADCSRA |= (1<<ADEN);
// digital input buffer disable(24.9.5)
DIDR0 = (1<<ADC0D) | (1<<ADC4D) | (1<<ADC5D) | (1<<ADC7D);
DIDR1 = (1<<AIN0D);
@@ -92,23 +91,13 @@ uint16_t battery_voltage(void)
PORTF |= (1<<4);
volatile uint16_t bat;
- //ADCSRA |= (1<<ADEN);
-
- // discard first result
- ADCSRA |= (1<<ADSC);
- while (ADCSRA & (1<<ADSC)) ;
- bat = ADC;
-
- // discard second result
- ADCSRA |= (1<<ADSC);
- while (ADCSRA & (1<<ADSC)) ;
- bat = ADC;
+ ADCSRA |= (1<<ADEN);
ADCSRA |= (1<<ADSC);
while (ADCSRA & (1<<ADSC)) ;
bat = ADC;
- //ADCSRA &= ~(1<<ADEN);
+ ADCSRA &= ~(1<<ADEN);
// ADC disable voltate divider(PF4)
DDRF |= (1<<4);