Date:2011-03-11 21:32:39 (8 years 8 months ago)
Author:Werner Almesberger
Commit:2978afe92b395305a002c6615676e9cb992989eb
Message: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
Files: atusb/fw/flash.c (1 diff)

Change Details

atusb/fw/flash.c
4040    static uint8_t last;
4141        const uint8_t *p;
4242
43    eeprom_busy_wait();
4443    for (p = buf; p != buf+size; p++) {
4544        if (!(payload & (SPM_PAGESIZE-1))) {
46            if (payload) {
47                boot_page_write(payload-SPM_PAGESIZE);
48                boot_spm_busy_wait();
49            }
5045            boot_page_erase(payload);
5146            boot_spm_busy_wait();
5247        }
48
5349        if (payload & 1)
54            boot_page_fill(payload, last | (*p << 0));
50            boot_page_fill(payload, last | (*p << 8));
5551        else
5652            last = *p;
5753        payload++;
58        }
5954
60    if (!(payload & (SPM_PAGESIZE-1))) {
61        boot_page_write(payload);
62        boot_spm_busy_wait();
63    }
55        if (!(payload & (SPM_PAGESIZE-1))) {
56            boot_page_write(payload-SPM_PAGESIZE);
57            boot_spm_busy_wait();
58        }
59        }
6460
6561    boot_rww_enable();
6662}

Archive Download the corresponding diff file



interactive