added beeper
This commit is contained in:
parent
eacfc70af9
commit
e002bb20e4
4
Makefile
4
Makefile
@ -47,5 +47,5 @@ bin: $(PRG).bin
|
||||
$(OBJCOPY) -j .text -j .data -O binary $< $@
|
||||
|
||||
install: text
|
||||
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
|
||||
# uisp -dprog=avr910 -dserial=/dev/ttyS0 -dspeed=115200 -dpart=M8 --erase --upload if=$(PRG).hex
|
||||
avrdude -p m8 -c butterfly -b 115200 -P /dev/ttyUSB0 -u -e -U flash:w:$(PRG).hex
|
||||
|
@ -50,6 +50,7 @@
|
||||
*/
|
||||
#define CH0 PORTC0
|
||||
#define CH1 PORTC1
|
||||
#define SUMMER PORTB0
|
||||
#define PWM PORTB1
|
||||
|
||||
#define NOP asm volatile ("nop")
|
||||
@ -60,7 +61,7 @@
|
||||
|
||||
#define VOLTAGE_CONNECT 9000
|
||||
#define VOLTAGE_CHARGE 12450
|
||||
#define CURRENT_CHARGE 16000
|
||||
#define CURRENT_CHARGE 17500
|
||||
#define CURRENT_READY 2000
|
||||
#define VOLTAGE_REMOVE 1000
|
||||
|
||||
@ -223,6 +224,9 @@ ISR(TIMER0_OVF_vect)
|
||||
lcd_update = 1;
|
||||
}
|
||||
|
||||
static uint16_t beep_timer;
|
||||
beep_timer = (beep_timer +1) & 0x3FF;
|
||||
|
||||
/*
|
||||
* charge with constant voltage of 12.45V
|
||||
* and a current limit of 1.6A
|
||||
@ -243,6 +247,11 @@ ISR(TIMER0_OVF_vect)
|
||||
TCCR1A &= ~(1<<COM1A1);
|
||||
}
|
||||
|
||||
if (mode == MOD_READY && beep_timer < 0x03)
|
||||
PORTB &= ~(1<<SUMMER);
|
||||
else
|
||||
PORTB |= (1<<SUMMER);
|
||||
|
||||
switch (mode) {
|
||||
case MOD_WAITING:
|
||||
/* start charging when a voltage > 9V is detected (lipo connected) */
|
||||
@ -266,7 +275,7 @@ ISR(TIMER0_OVF_vect)
|
||||
|
||||
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);
|
||||
|
||||
/* Set baud rate 19200 */
|
||||
|
Loading…
Reference in New Issue
Block a user