Sample program showing a software method to initiate reload and subsequent reset of the target without pressing the reset button.
Revision 0:0230dff6c24f, committed 2012-02-15
- Comitter:
- peterand
- Date:
- Wed Feb 15 15:27:25 2012 +0000
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 0230dff6c24f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Feb 15 15:27:25 2012 +0000 @@ -0,0 +1,44 @@ +#include "mbed.h" + +/* connect a "wedge" between an arbitrary digital pin (p5 in this example) and nR (pin4)*/ + +Serial pc(USBTX, USBRX); +DigitalInOut reset(p5); +LocalFileSystem local("local"); +//FILE *fp; + +int main() { + + pc.baud(115200); + char filename[64]; + int n = 0; + + while(1) { + sprintf(filename, "/local/reset%03d.txt", n); + FILE *fp = fopen(filename, "r"); + if(fp == NULL) { + break; + } + fclose(fp); + n++; + } + + FILE *fp = fopen(filename, "w"); + fprintf(fp, "Reset # %d\n", n); + fclose(fp); + + pc.printf("\nThis was reset # %u\n", n); + pc.printf("Press 'R' to reset (and reload) the target\n"); + + while(1) { + if (pc.readable()){ + char c = pc.getc(); + if(c== 'R'){ + pc.printf("\nReset! Bye, bye...\n"); + reset.output(); +/* reset.write(0); not necessary*/ + } + else pc.printf("Got %c\n",c); + } + } +} \ No newline at end of file
diff -r 000000000000 -r 0230dff6c24f mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Feb 15 15:27:25 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912