From: dragorn Date: Fri, 22 Jan 2010 20:06:45 +0000 (+0000) Subject: Add soft-reboot via 5x+ 0x80 written to serial (allow firmware to run on X-Git-Url: http://git.rot13.org/?p=goodfet;a=commitdiff_plain;h=6e4a1014e1ddfdf63dbf07fa3fdcaa1fdca99bab Add soft-reboot via 5x+ 0x80 written to serial (allow firmware to run on hardware variants which do not have DTR, such as bluetooth bridges driven as rfcomm serial channels, not serial ports) git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@275 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- 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();