Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@6:78a965b2d2df, 2014-04-14 (annotated)
- Committer:
- silverpanda
- Date:
- Mon Apr 14 01:53:10 2014 +0000
- Revision:
- 6:78a965b2d2df
- Parent:
- 5:03b7c237c4c4
- Child:
- 7:19da09fe546b
small improvements
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
silverpanda | 0:6898e364f29a | 1 | // Print "Hello World" to the PC |
silverpanda | 0:6898e364f29a | 2 | |
silverpanda | 0:6898e364f29a | 3 | #include "mbed.h" |
silverpanda | 5:03b7c237c4c4 | 4 | #include "shell.h" |
silverpanda | 0:6898e364f29a | 5 | |
silverpanda | 6:78a965b2d2df | 6 | Ticker *scanTicker; |
silverpanda | 6:78a965b2d2df | 7 | Shell *usbSerialShell; |
silverpanda | 3:7188bd978801 | 8 | bool scanUSBSerialRxFlag; |
silverpanda | 1:20033a89af0e | 9 | |
silverpanda | 1:20033a89af0e | 10 | void setScanUSBSerialRxFlag() |
silverpanda | 1:20033a89af0e | 11 | { |
silverpanda | 1:20033a89af0e | 12 | scanUSBSerialRxFlag = true; |
silverpanda | 1:20033a89af0e | 13 | } |
silverpanda | 1:20033a89af0e | 14 | //----------------------------------------------------------------------------- |
silverpanda | 1:20033a89af0e | 15 | |
silverpanda | 1:20033a89af0e | 16 | void initMain() |
silverpanda | 1:20033a89af0e | 17 | { |
silverpanda | 4:dfb672184380 | 18 | // increase the baud rate for the USB serial port |
silverpanda | 5:03b7c237c4c4 | 19 | usbSerialShell = new Shell(115200); |
silverpanda | 1:20033a89af0e | 20 | |
silverpanda | 4:dfb672184380 | 21 | // send greeting with first cursor |
silverpanda | 5:03b7c237c4c4 | 22 | usbSerialShell->sendHelloWorld(); |
silverpanda | 1:20033a89af0e | 23 | |
silverpanda | 4:dfb672184380 | 24 | // start polling for characters |
silverpanda | 6:78a965b2d2df | 25 | scanTicker = new Ticker(); |
silverpanda | 6:78a965b2d2df | 26 | scanTicker->attach(&setScanUSBSerialRxFlag, 0.01); |
silverpanda | 1:20033a89af0e | 27 | scanUSBSerialRxFlag = false; |
silverpanda | 0:6898e364f29a | 28 | } |
silverpanda | 0:6898e364f29a | 29 | //----------------------------------------------------------------------------- |
silverpanda | 0:6898e364f29a | 30 | |
silverpanda | 0:6898e364f29a | 31 | int main() { |
silverpanda | 1:20033a89af0e | 32 | initMain(); |
silverpanda | 1:20033a89af0e | 33 | |
silverpanda | 4:dfb672184380 | 34 | while(true) { |
silverpanda | 4:dfb672184380 | 35 | |
silverpanda | 4:dfb672184380 | 36 | // check the flag |
silverpanda | 5:03b7c237c4c4 | 37 | if(scanUSBSerialRxFlag) { |
silverpanda | 5:03b7c237c4c4 | 38 | usbSerialShell->scanUSBSerialRx(); |
silverpanda | 5:03b7c237c4c4 | 39 | scanUSBSerialRxFlag = false; |
silverpanda | 5:03b7c237c4c4 | 40 | } |
silverpanda | 4:dfb672184380 | 41 | |
silverpanda | 4:dfb672184380 | 42 | // give the main loop some time |
silverpanda | 1:20033a89af0e | 43 | wait(0.02); |
silverpanda | 0:6898e364f29a | 44 | } |
silverpanda | 0:6898e364f29a | 45 | } |
silverpanda | 0:6898e364f29a | 46 | //----------------------------------------------------------------------------- |