S K UCI
/
an_m0interface_stall_test
simple test program to demonstrate a (random) stalling of the mbed on a call to the interface chip
main.cpp@0:fcbed0c42196, 2015-01-21 (annotated)
- Committer:
- uci1
- Date:
- Wed Jan 21 05:04:32 2015 +0000
- Revision:
- 0:fcbed0c42196
simple test of stalling an mbed on a call to the interface chip
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uci1 | 0:fcbed0c42196 | 1 | #include "mbed.h" |
uci1 | 0:fcbed0c42196 | 2 | |
uci1 | 0:fcbed0c42196 | 3 | #include "Watchdog.h" |
uci1 | 0:fcbed0c42196 | 4 | |
uci1 | 0:fcbed0c42196 | 5 | extern "C" void mbed_mac_address(char *); |
uci1 | 0:fcbed0c42196 | 6 | |
uci1 | 0:fcbed0c42196 | 7 | int main() { |
uci1 | 0:fcbed0c42196 | 8 | |
uci1 | 0:fcbed0c42196 | 9 | DigitalOut led1(LED1,1); |
uci1 | 0:fcbed0c42196 | 10 | |
uci1 | 0:fcbed0c42196 | 11 | Watchdog::kick(15); |
uci1 | 0:fcbed0c42196 | 12 | |
uci1 | 0:fcbed0c42196 | 13 | DigitalOut led2(LED2,1); |
uci1 | 0:fcbed0c42196 | 14 | DigitalOut led3(LED3,0); |
uci1 | 0:fcbed0c42196 | 15 | DigitalOut led4(LED4,0); |
uci1 | 0:fcbed0c42196 | 16 | |
uci1 | 0:fcbed0c42196 | 17 | // show result of interface_connected via LEDs |
uci1 | 0:fcbed0c42196 | 18 | if (mbed_interface_connected()) { |
uci1 | 0:fcbed0c42196 | 19 | led4 = 1; |
uci1 | 0:fcbed0c42196 | 20 | } else { |
uci1 | 0:fcbed0c42196 | 21 | led3 = 1; |
uci1 | 0:fcbed0c42196 | 22 | } |
uci1 | 0:fcbed0c42196 | 23 | |
uci1 | 0:fcbed0c42196 | 24 | // may stall here if M0 chip not available |
uci1 | 0:fcbed0c42196 | 25 | static const uint8_t b64 = sizeof(uint64_t); |
uci1 | 0:fcbed0c42196 | 26 | static char c[b64]; |
uci1 | 0:fcbed0c42196 | 27 | mbed_mac_address(&(c[0])); |
uci1 | 0:fcbed0c42196 | 28 | |
uci1 | 0:fcbed0c42196 | 29 | // turn off led1 to indicate we made it here |
uci1 | 0:fcbed0c42196 | 30 | led1 = 0; |
uci1 | 0:fcbed0c42196 | 31 | |
uci1 | 0:fcbed0c42196 | 32 | // reset quickly |
uci1 | 0:fcbed0c42196 | 33 | Watchdog::kick(2); |
uci1 | 0:fcbed0c42196 | 34 | while(true) { |
uci1 | 0:fcbed0c42196 | 35 | // blink to show we're running |
uci1 | 0:fcbed0c42196 | 36 | led2 = !led2; |
uci1 | 0:fcbed0c42196 | 37 | wait(0.1); |
uci1 | 0:fcbed0c42196 | 38 | } |
uci1 | 0:fcbed0c42196 | 39 | } |