Add delete page fuction.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 11 Jun 2007 15:29:16 +0000 (15:29 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 11 Jun 2007 15:29:16 +0000 (15:29 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@803 38d2e660-2303-0410-9eaa-f027e97ec537

mware/prog_avr.c

index f2eac38fd9ed1080d78b66c8d860d5932045b415..70dd17410fcadd483f85e10c9819f0d954dfb8c9 100755 (executable)
@@ -98,6 +98,18 @@ static void prog_pagewrite(uint16_t addr)
 }
 
 
+/**
+ * Delete a page in program memory.
+ */
+static void prog_pagedelete(uint16_t addr)
+{
+       /* Page erase */
+       write_page(addr, BV(PGERS) + BV(SPMEN));
+
+       /* Re-enable the RWW section */
+       write_page(addr, BV(REENABLE_RWW_BIT) + BV(SPMEN));
+}
+
 /**
  * Flush temporary buffer into flash memory.
  */
@@ -111,6 +123,9 @@ static void prog_flush(void)
 
        wdt_reset();
 
+       /* Page delete */
+       prog_pagedelete(curr_page_num * PAGEBUF);
+
        /* Page write */
        prog_pagewrite(curr_page_num * PAGEBUF);
 }