diff --git a/bootloader/bootloader-usb.c b/bootloader/bootloader-usb.c index 2ba7d32ddff22a8cbcc70dfcd688214bec98a172..003d295a6a8ecc07f41cc74517de5861642c28f6 100644 --- a/bootloader/bootloader-usb.c +++ b/bootloader/bootloader-usb.c @@ -52,6 +52,8 @@ #include "descriptors.h" #include "mscmem.h" #include "card10.h" +#include "display.h" +#include "GUI_Paint.h" /***** Definitions *****/ #define EVENT_ENUM_COMP MAXUSB_NUM_EVENTS @@ -112,6 +114,17 @@ void delay_us(unsigned int usec) mxc_delay(usec); } +void bootloader_dirty(void) +{ + Paint_DrawString_EN(0, 16 * 3, "Writing.", &Font16, 0x0000, 0xf000); + LCD_Update(); +} +void bootloader_clean(void) +{ + Paint_DrawString_EN(0, 16 * 3, "Ready. ", &Font16, 0x0000, 0xffff); + LCD_Update(); +} + /******************************************************************************/ void run_usbmsc(void) { diff --git a/bootloader/main.c b/bootloader/main.c index 3bb2ba178fb787db374b0c9da78cf835b5c7e015..187ebcc7daba4d0ba96d4e4cccbcefd22a4e67cb 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -238,12 +238,10 @@ int main(void) // If the button is pressed, we go into MSC mode. if (PB_Get(3)) { Paint_DrawString_EN( - 0, - 16 * 2, - "USB activated. Waiting.", - &Font16, - 0x0000, - 0xffff + 0, 16 * 2, "USB activated.", &Font16, 0x0000, 0xffff + ); + Paint_DrawString_EN( + 0, 16 * 3, "Ready.", &Font16, 0x0000, 0xffff ); LCD_Update(); run_usbmsc(); diff --git a/bootloader/mscmem.c b/bootloader/mscmem.c index 8e2febd8da19c6d004c394fe1cbc9134fa477fc6..82d6ce8856661edc5a9dbe840aa3cb2afdd574bb 100644 --- a/bootloader/mscmem.c +++ b/bootloader/mscmem.c @@ -3,6 +3,11 @@ #include <stdio.h> #include "mx25lba.h" +void bootloader_dirty(void); +void bootloader_clean(void); + +static int dirty = 0; + /******************************************************************************/ int mscmem_init() { @@ -27,6 +32,10 @@ int mscmem_read(uint32_t lba, uint8_t *buffer) int mscmem_write(uint32_t lba, uint8_t *buffer) { //printf("%s\n", __func__); + if (dirty == 0) { + bootloader_dirty(); + } + dirty = 2; return mx25_write(lba, buffer); } @@ -48,5 +57,13 @@ int mscmem_stop() int mscmem_ready() { //printf("%s\n", __func__); + if (dirty) { + dirty--; + if (dirty == 0) { + printf("sync\n"); + mx25_sync(); + bootloader_clean(); + } + } return mx25_ready(); } diff --git a/lib/mx25lba/mx25lba.h b/lib/mx25lba/mx25lba.h index 11c0176d0d022ddab7dc04c1959be80803a10f2b..1aa09c2c2476e7332b1c56319b3401f0f0bf7f1b 100644 --- a/lib/mx25lba/mx25lba.h +++ b/lib/mx25lba/mx25lba.h @@ -52,5 +52,6 @@ uint32_t mx25_size(void); int mx25_read(uint32_t lba, uint8_t* buffer); int mx25_write(uint32_t lba, uint8_t* buffer); int mx25_ready(void); +int mx25_sync(void); #endif /* __MX25_H__ */