Simon Ford
/
TestAttach
Modifed version of http://mbed.org/forum/mbed/topic/506/ to make it functional
Revision 0:b744a6c42a5a, committed 2010-02-16
- Comitter:
- simon
- Date:
- Tue Feb 16 11:44:39 2010 +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 b744a6c42a5a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Feb 16 11:44:39 2010 +0000 @@ -0,0 +1,37 @@ +#include "mbed.h" + +void respondtoPC() ; + +Serial pc(USBTX, USBRX); // tx, rx + +DigitalOut myled(LED1); +volatile int test ; + +int main() { + struct tm t; + test = 0 ; + pc.attach(respondtoPC) ; + while (1) { + myled = !myled ; + if(test == 1) { + pc.attach(NULL); + printf("Enter current date and time: \n"); + printf("YYYY MM DD HH MM SS[enter] \n"); + scanf("%d %d %d %d %d %d", &t.tm_year, &t.tm_mon, &t.tm_mday + , &t.tm_hour, &t.tm_min, &t.tm_sec); +// adjust for tm structure required values + t.tm_year = t.tm_year - 1900; + t.tm_mon = t.tm_mon - 1; +// set the time + set_time(mktime(&t)); + printf("set time\n"); + pc.attach(respondtoPC); + } + wait(1) ; + } +} + +void respondtoPC() { + char dummy = pc.getc() ; + test++ ; +} \ No newline at end of file
diff -r 000000000000 -r b744a6c42a5a mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Feb 16 11:44:39 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0