From 553c981551fdf18361e076a26e6fe7427fd2f217 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 11 Mar 2011 17:27:03 -0300 Subject: [PATCH] atusb/fw/flash.c: implemented flash_can_write and flash_read (were stubs) --- atusb/fw/flash.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/atusb/fw/flash.c b/atusb/fw/flash.c index cd29b5b..3b12a56 100644 --- a/atusb/fw/flash.c +++ b/atusb/fw/flash.c @@ -14,6 +14,7 @@ #include #include +#include #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; }