aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKing Kévin <kingkevin@cuvoodoo.info>2014-08-02 15:07:35 -0700
committerKing Kévin <kingkevin@cuvoodoo.info>2014-08-02 15:07:35 -0700
commit1f05f5a8b8ab840c8ddd7de046ce9d3bd6b8bf26 (patch)
treeb89667a3395753747bc03d51ecc8dcc1bdef33ce
parent7af0a8a5b88b6873286056cf43eeefc1162a4c09 (diff)
implemented clear_memory()
-rw-r--r--pic/MDR/MDR.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/pic/MDR/MDR.c b/pic/MDR/MDR.c
index 3c04e30..d362e2c 100644
--- a/pic/MDR/MDR.c
+++ b/pic/MDR/MDR.c
@@ -233,27 +233,28 @@ void save_code()
void clear_memory(void)
{
uint16_t address;
- uint8_t stored[3];
- /* start at begining of the memory */
- send_start();
- if (send_byte(0xa0)) { /* write address to eeprom at 0xA0/0x50 */
- send_stop();
- return;
- }
- if (send_byte(0x00)) { /* go to address 0x0000 */
- send_stop();
- return;
- }
- if (send_byte(0x00)) { /* go to address 0x0000 */
- send_stop();
- return;
- }
/* go through memory */
for (address=0; address<0x7FFF; address++) {
+ if ((address%0x40)==0) { /* select page */
+ send_start(); /* start transaction */
+ if (send_byte(0xa0)) { /* write address to eeprom at 0xA0/0x50 */
+ send_stop();
+ return;
+ }
+ if (send_byte(address>>8)) { /* go to address */
+ send_stop();
+ return;
+ }
+ if (send_byte(address&0xff)) { /* go to address */
+ send_stop();
+ return;
+ }
+ }
send_byte(0x00); /* clear byte */
+ if ((address%0x40)==0x3f) { /* end of page */
+ send_stop(); /* finish transaction */
+ }
}
- send_stop(); /* finish transaction */
-
}
/* funcion called on interrupts */