diff options
author | Cristian Maglie <c.maglie@bug.st> | 2013-03-07 22:09:41 +0100 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2013-03-07 22:09:41 +0100 |
commit | a6f7480034697fe5f48667ca978fea9eedcaa066 (patch) | |
tree | 79f0c1c618cad37c7da1d67ec837c64e6b8b16db /bootloaders/stk500v2/stk500boot.c | |
parent | 095e99aae5c4e94e06382ca40a0b00bae05a7f3a (diff) |
Mega2560 bootloader: use avr library functions for writing into EEPROM
Diffstat (limited to 'bootloaders/stk500v2/stk500boot.c')
-rw-r--r--[-rwxr-xr-x] | bootloaders/stk500v2/stk500boot.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/bootloaders/stk500v2/stk500boot.c b/bootloaders/stk500v2/stk500boot.c index 104ab3b..e7494df 100755..100644 --- a/bootloaders/stk500v2/stk500boot.c +++ b/bootloaders/stk500v2/stk500boot.c @@ -1020,24 +1020,15 @@ int main(void) } else { - //* issue 543, this should work, It has not been tested. - #if (defined(EEARL) && defined(EEARH) && defined(EEMWE) && defined(EEWE) && defined(EEDR)) + //* issue 543, this should work, It has not been tested. uint16_t ii = address >> 1; /* write EEPROM */ - do { - EEARL = ii; // Setup EEPROM address - EEARH = (ii >> 8); + while (size) { + eeprom_write_byte((uint8_t*)ii, *p++); address+=2; // Select next EEPROM byte ii++; - - EEDR = *p++; // get byte from buffer - EECR |= (1<<EEMWE); // Write data into EEPROM - EECR |= (1<<EEWE); - - while (EECR & (1<<EEWE)); // Wait for write operation to finish - size--; // Decrease number of bytes to write - } while (size); // Loop until all bytes written - #endif + size--; + } } msgLength = 2; msgBuffer[1] = STATUS_CMD_OK; |