This commit is contained in:
Olaf Rempel 2007-10-05 23:18:51 +02:00
parent 18cb2f29c7
commit 82fd0d1138

View File

@ -195,6 +195,7 @@ ISR(ADC_vect)
ADMUX = CH1; ADMUX = CH1;
} }
/* start ADC again */
ADCSRA |= (1<<ADSC); ADCSRA |= (1<<ADSC);
} }
@ -218,7 +219,7 @@ ISR(TIMER0_OVF_vect)
/* /*
* charge with constant voltage of 12.45V * charge with constant voltage of 12.45V
* and a current limit of 1.6V * and a current limit of 1.6A
*/ */
if (mode == MOD_CHARGING) { if (mode == MOD_CHARGING) {
if (voltage < 12425 && current < 15500) if (voltage < 12425 && current < 15500)
@ -228,30 +229,23 @@ ISR(TIMER0_OVF_vect)
if (voltage > 12450 || current > 16000) if (voltage > 12450 || current > 16000)
if (pwm > 0x00) if (pwm > 0x00)
pwm--; pwm--;
} else {
pwm = 0;
}
if (pwm > 0) {
OCR1A = pwm; OCR1A = pwm;
TCCR1A |= (1<<COM1A1); TCCR1A |= (1<<COM1A1);
} else { } else {
pwm = 0;
TCCR1A &= ~(1<<COM1A1); TCCR1A &= ~(1<<COM1A1);
} }
switch (mode) { switch (mode) {
case MOD_WAITING: case MOD_WAITING:
/* /* start charging when a voltage > 9V is detected (lipo connected) */
* start charging when a voltage > 9V is detected (lipo connected)
*/
if (voltage > 9000) if (voltage > 9000)
mode = MOD_CHARGING; mode = MOD_CHARGING;
break; break;
case MOD_CHARGING: case MOD_CHARGING:
/* /* end charging if voltage > 12.42V and current < 200mA */
* end charging if voltage > 12.42V and current < 200mA
*/
if (voltage > 12425 && current < 2000) if (voltage > 12425 && current < 2000)
mode = MOD_READY; mode = MOD_READY;
break; break;