/*************************************************************************** * Copyright (C) 09/2007 by Olaf Rempel * * razzor@kopf-tisch.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; version 2 of the License, * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #define F_CPU 8000000 #include #define ADC_REF PORTA0 #define ADC_U PORTA1 #define ADC_IM PORTA2 #define ADC_IP PORTA3 #define SUMMER PORTA7 #define LEDRT PORTB0 #define LEDGN PORTB1 #define PWM PORTB2 /* ADC_U vs GND: voltage with prescaler (12V -> 2V; 15mV -> 2.5mV/bit), ref 2.56V */ #define CH_U ((1< 100mV; ??mA -> ?mV/bit), gain x20, ref 5V */ #define CH_I ((0< VOLTAGE_CHARGE || current > CURRENT_CHARGE) if (pwm > 0x00) pwm--; OCR0A = pwm; TCCR0A |= (1< 9V is detected (lipo connected) */ if (voltage > VOLTAGE_CONNECT) mode = MOD_CHARGING; break; case MOD_CHARGING: /* current limit */ if (voltage < (VOLTAGE_CHARGE -50)) { /* green on, red fast blinking */ if (led_timer & 0x80) PORTB &= ~((1< 12.45V and current < 200mA */ if (voltage >= VOLTAGE_CHARGE && current < CURRENT_READY) mode = MOD_READY; break; case MOD_READY: /* green on, red flashing */ if (led_timer < 0x3F) PORTB &= ~((1<