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@5:03b7c237c4c4, 2014-04-14 (annotated)
- Committer:
- silverpanda
- Date:
- Mon Apr 14 01:47:31 2014 +0000
- Revision:
- 5:03b7c237c4c4
- Parent:
- 4:dfb672184380
- Child:
- 6:78a965b2d2df
made separate "Shell"-class
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 | 1:20033a89af0e | 6 | Ticker messageTicker, scanTicker; |
| silverpanda | 3:7188bd978801 | 7 | bool scanUSBSerialRxFlag; |
| silverpanda | 5:03b7c237c4c4 | 8 | Shell *usbSerialShell; |
| 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 | 1:20033a89af0e | 25 | scanTicker.attach(&setScanUSBSerialRxFlag, 0.01); |
| silverpanda | 1:20033a89af0e | 26 | scanUSBSerialRxFlag = false; |
| silverpanda | 0:6898e364f29a | 27 | } |
| silverpanda | 0:6898e364f29a | 28 | //----------------------------------------------------------------------------- |
| silverpanda | 0:6898e364f29a | 29 | |
| silverpanda | 0:6898e364f29a | 30 | int main() { |
| silverpanda | 1:20033a89af0e | 31 | initMain(); |
| silverpanda | 1:20033a89af0e | 32 | |
| silverpanda | 4:dfb672184380 | 33 | while(true) { |
| silverpanda | 4:dfb672184380 | 34 | |
| silverpanda | 4:dfb672184380 | 35 | // check the flag |
| silverpanda | 5:03b7c237c4c4 | 36 | if(scanUSBSerialRxFlag) { |
| silverpanda | 5:03b7c237c4c4 | 37 | usbSerialShell->scanUSBSerialRx(); |
| silverpanda | 5:03b7c237c4c4 | 38 | scanUSBSerialRxFlag = false; |
| silverpanda | 5:03b7c237c4c4 | 39 | } |
| silverpanda | 4:dfb672184380 | 40 | |
| silverpanda | 4:dfb672184380 | 41 | // give the main loop some time |
| silverpanda | 1:20033a89af0e | 42 | wait(0.02); |
| silverpanda | 0:6898e364f29a | 43 | } |
| silverpanda | 0:6898e364f29a | 44 | } |
| silverpanda | 0:6898e364f29a | 45 | //----------------------------------------------------------------------------- |