Tianji Wu
/
syncSlave_3
syncSlave for problem 3
main.cpp@0:362932d519c6, 2010-12-03 (annotated)
- Committer:
- the729
- Date:
- Fri Dec 03 20:53:52 2010 +0000
- Revision:
- 0:362932d519c6
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
the729 | 0:362932d519c6 | 1 | #include "mbed.h" |
the729 | 0:362932d519c6 | 2 | #include "timesync.h" |
the729 | 0:362932d519c6 | 3 | |
the729 | 0:362932d519c6 | 4 | DigitalOut myled(LED2); |
the729 | 0:362932d519c6 | 5 | DigitalOut mypin(p21); |
the729 | 0:362932d519c6 | 6 | |
the729 | 0:362932d519c6 | 7 | timeval_t t; |
the729 | 0:362932d519c6 | 8 | |
the729 | 0:362932d519c6 | 9 | void pinToggle() |
the729 | 0:362932d519c6 | 10 | { |
the729 | 0:362932d519c6 | 11 | mypin = 1; |
the729 | 0:362932d519c6 | 12 | myled = 1; |
the729 | 0:362932d519c6 | 13 | mypin = 0; |
the729 | 0:362932d519c6 | 14 | myled = 0; |
the729 | 0:362932d519c6 | 15 | t.tv_sec += 1; |
the729 | 0:362932d519c6 | 16 | runAtTime(&pinToggle, &t); |
the729 | 0:362932d519c6 | 17 | } |
the729 | 0:362932d519c6 | 18 | |
the729 | 0:362932d519c6 | 19 | int main() { |
the729 | 0:362932d519c6 | 20 | timesync_init(); |
the729 | 0:362932d519c6 | 21 | |
the729 | 0:362932d519c6 | 22 | t.tv_sec = 5; |
the729 | 0:362932d519c6 | 23 | t.tv_usec = 500000; |
the729 | 0:362932d519c6 | 24 | runAtTime(&pinToggle, &t); |
the729 | 0:362932d519c6 | 25 | while(1) { |
the729 | 0:362932d519c6 | 26 | } |
the729 | 0:362932d519c6 | 27 | } |