implemented clear_memory()

This commit is contained in:
King Kévin 2014-08-02 15:07:35 -07:00
parent 7af0a8a5b8
commit 1f05f5a8b8
1 changed files with 18 additions and 17 deletions

View File

@ -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 */