diff options
author | Martyn Ranyard <ranyardm@gmail.com> | 2012-11-02 21:45:58 +0000 |
---|---|---|
committer | Cristian Maglie <c.maglie@arduino.cc> | 2015-07-14 12:55:22 +0200 |
commit | d76d58a12e6982c54ca8a1d51b96fb9f864fc569 (patch) | |
tree | f389796f3a514ac7d876059885d17ce4a9006800 /bootloaders/bt/ATmegaBOOT_168.c | |
parent | 10da8ab42f635b96bb848574e446bf32a9e4165b (diff) |
Bootloaders: adds support for 328-nonp chips
Diffstat (limited to 'bootloaders/bt/ATmegaBOOT_168.c')
-rw-r--r-- | bootloaders/bt/ATmegaBOOT_168.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/bootloaders/bt/ATmegaBOOT_168.c b/bootloaders/bt/ATmegaBOOT_168.c index c73eefa..7ce2832 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 */ -#if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__) +#if !defined(__AVR_ATmega168__) || !defined(__AVR_ATmega328P__) || !defined(__AVR_ATmega328__) #include <avr/eeprom.h> #endif @@ -194,6 +194,11 @@ #define SIG3 0x0F #define PAGE_SIZE 0x40U //64 words +#elif defined __AVR_ATmega328__ +#define SIG2 0x95 +#define SIG3 0x14 +#define PAGE_SIZE 0x40U //64 words + #elif defined __AVR_ATmega162__ #define SIG2 0x94 #define SIG3 0x04 @@ -335,7 +340,7 @@ int main(void) UBRRHI = (F_CPU/(BAUD_RATE*16L)-1) >> 8; UCSRA = 0x00; UCSRB = _BV(TXEN)|_BV(RXEN); -#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) UBRR0H = ((F_CPU / 16 + BAUD_RATE / 2) / BAUD_RATE - 1) >> 8; UBRR0L = ((F_CPU / 16 + BAUD_RATE / 2) / BAUD_RATE - 1); @@ -557,7 +562,7 @@ putch(0x0D); if (getch() == ' ') { if (flags.eeprom) { //Write to EEPROM one byte at a time for(w=0;w<length.word;w++) { -#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) while(EECR & (1<<EEPE)); EEAR = (uint16_t)(void *)address.word; EEDR = buff[w]; @@ -675,7 +680,7 @@ putch(0x0D); "rjmp write_page \n\t" "block_done: \n\t" "clr __zero_reg__ \n\t" //restore zero register -#if defined __AVR_ATmega168__ || __AVR_ATmega328P__ +#if defined __AVR_ATmega168__ || __AVR_ATmega328P__ || __AVR_ATmega_328__ : "=m" (SPMCSR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31" #else : "=m" (SPMCR) : "M" (PAGE_SIZE) : "r0","r16","r17","r24","r25","r28","r29","r30","r31" @@ -707,7 +712,7 @@ putch(0x0D); putch(0x14); for (w=0;w < length.word;w++) { // Can handle odd and even lengths okay if (flags.eeprom) { // Byte access EEPROM read -#if defined __AVR_ATmega168__ || __AVR_ATmega328P__ +#if defined __AVR_ATmega168__ || __AVR_ATmega328P__ || __AVR_ATmega328__ while(EECR & (1<<EEPE)); EEAR = (uint16_t)(void *)address.word; EECR |= (1<<EERE); @@ -921,7 +926,7 @@ void putch(char ch) while (!(UCSR1A & _BV(UDRE1))); UDR1 = ch; } -#elif defined (__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#elif defined (__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) while (!(UCSR0A & _BV(UDRE0))); UDR0 = ch; #else @@ -944,7 +949,7 @@ char getch(void) return UDR1; } return 0; -#elif defined (__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#elif defined (__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) uint32_t count = 0; while(!(UCSR0A & _BV(RXC0))){ /* 20060803 DojoCorp:: Addon coming from the previous Bootloader*/ @@ -982,7 +987,7 @@ void getNch(uint8_t count) while(!(UCSR1A & _BV(RXC1))); UDR1; } -#elif (defined __AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#elif (defined __AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) while(!(UCSR0A & _BV(RXC0))); UDR0; #else |