X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Fgoodfet.c;h=53591509c91d11d567ba031b7a09803f35a642a5;hp=2fe74e14046c47e90401d432f8bf7afbbd3ff008;hb=6e4a1014e1ddfdf63dbf07fa3fdcaa1fdca99bab;hpb=d5c3f195610aeb972f3160ab74ca886db78154d5 diff --git a/firmware/goodfet.c b/firmware/goodfet.c index 2fe74e1..5359150 100644 --- a/firmware/goodfet.c +++ b/firmware/goodfet.c @@ -87,6 +87,9 @@ int main(void) volatile unsigned int i; unsigned char app, verb; unsigned long len; + // MSP reboot count for reset input & reboot function located at 0xFFFE + volatile unsigned int reset_count = 0; + void (*reboot_function)(void) = (void *) 0xFFFE; init(); @@ -97,6 +100,25 @@ int main(void) while(1){ //Magic 3 app=serial_rx(); + + // If the app is the reset byte (0x80) increment and loop + if (app == 0x80) { + reset_count++; + + if (reset_count > 4) { + // We could trigger the WDT with either: + // WDTCTL = 0; + // or + // WDTCTL = WDTPW + WDTCNTCL + WDTSSEL + 0x00; + // but instead we'll jump to our reboot function pointer + (*reboot_function)(); + } + + continue; + } else { + reset_count = 0; + } + verb=serial_rx(); //len=serial_rx(); len=rxword();