From 8a2387e805a3cc8f8fb18fe2ab4da857bd8c32b6 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 7 Aug 2010 19:48:59 +0000 Subject: Adding ATmega328 version of the Arduino BT bootloader, along with a Makefile for building it. --- bootloaders/bt/ATmegaBOOT_168.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'bootloaders/bt/ATmegaBOOT_168.c') diff --git a/bootloaders/bt/ATmegaBOOT_168.c b/bootloaders/bt/ATmegaBOOT_168.c index a85dc9a..c73eefa 100644 --- a/bootloaders/bt/ATmegaBOOT_168.c +++ b/bootloaders/bt/ATmegaBOOT_168.c @@ -79,7 +79,7 @@ /* the current avr-libc eeprom functions do not support the ATmega168 */ /* own eeprom write/read functions are used instead */ -#ifndef __AVR_ATmega168__ +#if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__) #include #endif @@ -189,6 +189,11 @@ #define SIG3 0x06 #define PAGE_SIZE 0x40U //64 words +#elif defined __AVR_ATmega328P__ +#define SIG2 0x95 +#define SIG3 0x0F +#define PAGE_SIZE 0x40U //64 words + #elif defined __AVR_ATmega162__ #define SIG2 0x94 #define SIG3 0x04 @@ -330,7 +335,8 @@ int main(void) UBRRHI = (F_CPU/(BAUD_RATE*16L)-1) >> 8; UCSRA = 0x00; UCSRB = _BV(TXEN)|_BV(RXEN); -#elif defined __AVR_ATmega168__ +#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) + UBRR0H = ((F_CPU / 16 + BAUD_RATE / 2) / BAUD_RATE - 1) >> 8; UBRR0L = ((F_CPU / 16 + BAUD_RATE / 2) / BAUD_RATE - 1); @@ -551,7 +557,7 @@ putch(0x0D); if (getch() == ' ') { if (flags.eeprom) { //Write to EEPROM one byte at a time for(w=0;w