From: asterix Date: Mon, 11 Jun 2007 15:29:16 +0000 (+0000) Subject: Add delete page fuction. X-Git-Tag: 1.0.0~438 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=05e674a9f236bdef3bcebeb4fc9dc763930e23df;p=bertos.git Add delete page fuction. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@803 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/mware/prog_avr.c b/mware/prog_avr.c index f2eac38f..70dd1741 100755 --- a/mware/prog_avr.c +++ b/mware/prog_avr.c @@ -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); }