added beeper

This commit is contained in:
Olaf Rempel 2008-03-25 20:15:41 +01:00
parent eacfc70af9
commit e002bb20e4
2 changed files with 13 additions and 4 deletions

View File

@ -47,5 +47,5 @@ bin: $(PRG).bin
$(OBJCOPY) -j .text -j .data -O binary $< $@ $(OBJCOPY) -j .text -j .data -O binary $< $@
install: text install: text
uisp -dprog=avr910 -dserial=/dev/ttyS0 -dspeed=115200 -dpart=M8 --erase --upload if=$(PRG).hex # uisp -dprog=avr910 -dserial=/dev/ttyS0 -dspeed=115200 -dpart=M8 --erase --upload if=$(PRG).hex
# avrdude -p m8 -c butterfly -b 19200 -P /dev/ttyUSB0 -u -e -U flash:w:$(PRG).hex avrdude -p m8 -c butterfly -b 115200 -P /dev/ttyUSB0 -u -e -U flash:w:$(PRG).hex

View File

@ -50,6 +50,7 @@
*/ */
#define CH0 PORTC0 #define CH0 PORTC0
#define CH1 PORTC1 #define CH1 PORTC1
#define SUMMER PORTB0
#define PWM PORTB1 #define PWM PORTB1
#define NOP asm volatile ("nop") #define NOP asm volatile ("nop")
@ -60,7 +61,7 @@
#define VOLTAGE_CONNECT 9000 #define VOLTAGE_CONNECT 9000
#define VOLTAGE_CHARGE 12450 #define VOLTAGE_CHARGE 12450
#define CURRENT_CHARGE 16000 #define CURRENT_CHARGE 17500
#define CURRENT_READY 2000 #define CURRENT_READY 2000
#define VOLTAGE_REMOVE 1000 #define VOLTAGE_REMOVE 1000
@ -223,6 +224,9 @@ ISR(TIMER0_OVF_vect)
lcd_update = 1; lcd_update = 1;
} }
static uint16_t beep_timer;
beep_timer = (beep_timer +1) & 0x3FF;
/* /*
* charge with constant voltage of 12.45V * charge with constant voltage of 12.45V
* and a current limit of 1.6A * and a current limit of 1.6A
@ -243,6 +247,11 @@ ISR(TIMER0_OVF_vect)
TCCR1A &= ~(1<<COM1A1); TCCR1A &= ~(1<<COM1A1);
} }
if (mode == MOD_READY && beep_timer < 0x03)
PORTB &= ~(1<<SUMMER);
else
PORTB |= (1<<SUMMER);
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) */
@ -266,7 +275,7 @@ ISR(TIMER0_OVF_vect)
int main(void) int main(void)
{ {
DDRB = (1<<CS) | (1<<RS) | (1<<PWM); DDRB = (1<<CS) | (1<<RS) | (1<<PWM) | (1<<SUMMER);
DDRD = (LCD_DATA_MASK) | (1<<RW); DDRD = (LCD_DATA_MASK) | (1<<RW);
/* Set baud rate 19200 */ /* Set baud rate 19200 */