TestAttach
Published 16 Feb 2010, by
Simon Ford

No tags
« Back to documentation index
Show/hide line numbers
main.cpp Source File
main.cpp
00001 #include "mbed.h"
00002
00003 void respondtoPC() ;
00004
00005 Serial pc(USBTX, USBRX);
00006
00007 DigitalOut myled(LED1);
00008 volatile int test ;
00009
00010 int main() {
00011 struct tm t;
00012 test = 0 ;
00013 pc.attach(respondtoPC) ;
00014 while (1) {
00015 myled = !myled ;
00016 if(test == 1) {
00017 pc.attach(NULL);
00018 printf("Enter current date and time: \n");
00019 printf("YYYY MM DD HH MM SS[enter] \n");
00020 scanf("%d %d %d %d %d %d", &t.tm_year, &t.tm_mon, &t.tm_mday
00021 , &t.tm_hour, &t.tm_min, &t.tm_sec);
00022
00023 t.tm_year = t.tm_year - 1900;
00024 t.tm_mon = t.tm_mon - 1;
00025
00026 set_time(mktime(&t));
00027 printf("set time\n");
00028 pc.attach(respondtoPC);
00029 }
00030 wait(1) ;
00031 }
00032 }
00033
00034 void respondtoPC() {
00035 char dummy = pc.getc() ;
00036 test++ ;
00037 }