dump codes when booting
This commit is contained in:
parent
5a32c0c9a4
commit
9f35b7a8ef
|
@ -266,6 +266,45 @@ void clear_memory(void)
|
|||
}
|
||||
}
|
||||
|
||||
/* read all codes from memory */
|
||||
void dump_codes(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;
|
||||
}
|
||||
/* start reading */
|
||||
send_start();
|
||||
if (send_byte(0xa1)) { /* read eeprom at 0xA0/0x50 */
|
||||
send_stop();
|
||||
return;
|
||||
}
|
||||
/* go through memory */
|
||||
for (address=0; address<0x7FFF-2; address+=3) {
|
||||
/* read stored code */
|
||||
stored[0] = read_byte(1);
|
||||
stored[1] = read_byte(1);
|
||||
stored[2] = read_byte(1);
|
||||
if ((stored[0]&0x80)==0) { /* code always have the MSb to 1 */
|
||||
read_byte(0); /* send nack */
|
||||
send_stop(); /* end transaction */
|
||||
return; /* all codes have been read */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* funcion called on interrupts */
|
||||
/* interrupt 0 is only one on PIC16 */
|
||||
static void interrupt(void) __interrupt 0
|
||||
|
@ -308,6 +347,7 @@ void main (void)
|
|||
uint16_t new = 0; /* is the code new */
|
||||
|
||||
init(); /* configure micro-controller */
|
||||
dump_codes(); /* dump codes when powering up so a logic analyzer can get them */
|
||||
|
||||
while (1) { /* a microcontroller runs forever */
|
||||
/* I can't go to sleep to safe power
|
||||
|
|
Loading…
Reference in New Issue