1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-06-29 00:52:20 +03:00

atusb/fw/flash.c: simplified logic of flash_write and corrected several small bugs

- flash.c (flash_write): we don't use eeprom_busy_wait, removed it
- flash.c (flash_write): write the page only at one place
- flash.c (flash_write): corrected the address of the page write
- flash.c (flash_write): value being added to word wasn't shifted
This commit is contained in:
Werner Almesberger 2011-03-11 17:32:39 -03:00
parent 553c981551
commit 2978afe92b

View File

@ -40,27 +40,23 @@ void flash_write(const uint8_t *buf, uint16_t size)
static uint8_t last;
const uint8_t *p;
eeprom_busy_wait();
for (p = buf; p != buf+size; p++) {
if (!(payload & (SPM_PAGESIZE-1))) {
if (payload) {
boot_page_write(payload-SPM_PAGESIZE);
boot_spm_busy_wait();
}
boot_page_erase(payload);
boot_spm_busy_wait();
}
if (payload & 1)
boot_page_fill(payload, last | (*p << 0));
boot_page_fill(payload, last | (*p << 8));
else
last = *p;
payload++;
}
if (!(payload & (SPM_PAGESIZE-1))) {
boot_page_write(payload);
boot_spm_busy_wait();
}
if (!(payload & (SPM_PAGESIZE-1))) {
boot_page_write(payload-SPM_PAGESIZE);
boot_spm_busy_wait();
}
}
boot_rww_enable();
}