mega88 version

This commit is contained in:
Olaf Rempel 2008-06-17 18:02:07 +02:00
parent 96a79d970d
commit dbef89dc6e
2 changed files with 17 additions and 16 deletions

View File

@ -1,6 +1,6 @@
PRG = twiboot PRG = twiboot
OBJ = main.o OBJ = main.o
MCU_TARGET = atmega8 MCU_TARGET = atmega88
OPTIMIZE = -Os OPTIMIZE = -Os
DEFS = DEFS =
@ -41,4 +41,4 @@ 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=auto --erase --upload if=$(PRG).hex

29
main.c
View File

@ -45,8 +45,9 @@
* LED on PORTB4 blinks with 20Hz (while bootloader is running) * LED on PORTB4 blinks with 20Hz (while bootloader is running)
* LED on PORTB5 blinks on TWI activity * LED on PORTB5 blinks on TWI activity
* *
* Fuse H: 0xda (512 words bootloader) * Fuse E: 0xfa (512 words bootloader)
* Fuse L: 0x84 (8Mhz internal RC-Osz., 2.7V BOD) * Fuse H: 0xdd (2.7V BOD)
* Fuse L: 0xc2 (8Mhz internal RC-Osz.)
* *
* bootloader twi-protocol: * bootloader twi-protocol:
* - get info about bootloader: * - get info about bootloader:
@ -71,8 +72,8 @@
* SLA+W, 0x1F, STO * SLA+W, 0x1F, STO
*/ */
const static uint8_t info[16] = "TWIBOOT m8-v1.2"; const static uint8_t info[16] = "TWIBOOT m88-v12";
const static uint8_t signature[4] = { 0x1E, 0x93, 0x07, 0x00 }; const static uint8_t signature[4] = { 0x1E, 0x93, 0x0A, 0x00 };
/* wait 40 * 25ms = 1s */ /* wait 40 * 25ms = 1s */
volatile static uint8_t boot_timeout = 40; volatile static uint8_t boot_timeout = 40;
@ -115,8 +116,8 @@ void write_eeprom_byte(uint8_t val)
EEDR = val; EEDR = val;
addr++; addr++;
EECR |= (1<<EEMWE); EECR |= (1<<EEMPE);
EECR |= (1<<EEWE); EECR |= (1<<EEPE);
eeprom_busy_wait(); eeprom_busy_wait();
} }
@ -272,14 +273,14 @@ int main(void)
PORTB = LED_GN; PORTB = LED_GN;
/* move interrupt-vectors to bootloader */ /* move interrupt-vectors to bootloader */
GICR = (1<<IVCE); MCUCR = (1<<IVCE);
GICR = (1<<IVSEL); MCUCR = (1<<IVSEL);
/* timer0: running with F_CPU/1024 */ /* timer0: running with F_CPU/1024 */
TCCR0 = (1<<CS02) | (1<<CS00); TCCR0B = (1<<CS02) | (1<<CS00);
/* enable timer0 OVF interrupt */ /* enable timer0 OVF interrupt */
TIMSK |= (1<<TOIE0); TIMSK0 |= (1<<TOIE0);
/* TWI init: set address, auto ACKs with interrupts */ /* TWI init: set address, auto ACKs with interrupts */
TWAR = (TWI_ADDRESS<<1); TWAR = (TWI_ADDRESS<<1);
@ -293,12 +294,12 @@ int main(void)
TWCR = 0x00; TWCR = 0x00;
/* disable timer0 */ /* disable timer0 */
TIMSK = 0x00; TIMSK0 = 0x00;
TCCR0 = 0x00; TCCR0B = 0x00;
/* move interrupt vectors back to application */ /* move interrupt vectors back to application */
GICR = (1<<IVCE); MCUCR = (1<<IVCE);
GICR = (0<<IVSEL); MCUCR = (0<<IVSEL);
PORTB = 0x00; PORTB = 0x00;