1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-12-23 17:09:34 +02:00

atusb/fw/flash.c: implemented flash_can_write and flash_read (were stubs)

This commit is contained in:
Werner Almesberger 2011-03-11 17:27:03 -03:00
parent f87bdce41f
commit 553c981551

View File

@ -14,6 +14,7 @@
#include <stdint.h>
#include <avr/boot.h>
#include <avr/pgmspace.h>
#include "dfu.h"
#include "board.h"
@ -30,7 +31,7 @@ void flash_start(void)
int flash_can_write(uint16_t size)
{
return 1;
return payload+size <= BOOT_ADDR;
}
@ -67,5 +68,13 @@ void flash_write(const uint8_t *buf, uint16_t size)
uint16_t flash_read(uint8_t *buf, uint16_t size)
{
return 0;
uint16_t got = 0;
while (size && payload != (uint32_t) FLASHEND+1) {
*buf++ = pgm_read_byte(payload);
payload++;
size--;
got++;
}
return got;
}