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.
Fork of frdm_echo by
Diff: main.cpp
- Revision:
- 5:03b7c237c4c4
- Parent:
- 4:dfb672184380
- Child:
- 6:78a965b2d2df
--- a/main.cpp Mon Apr 14 00:45:29 2014 +0000 +++ b/main.cpp Mon Apr 14 01:47:31 2014 +0000 @@ -1,45 +1,11 @@ // Print "Hello World" to the PC #include "mbed.h" +#include "shell.h" -Serial usbSerial(USBTX, USBRX); Ticker messageTicker, scanTicker; bool scanUSBSerialRxFlag; - -void sendText(char *thisText) -{ - // this can send any text - usbSerial.printf(thisText); -} -//----------------------------------------------------------------------------- - -void sendHelloWorld() -{ - // sends the first greeting - sendText("** Hello World **\n\n> "); -} -//----------------------------------------------------------------------------- - -void scanUSBSerialRx() -{ - // check if there is something to read - if(usbSerial.readable()) { - - // if so ... - char character = usbSerial.getc(); - - // see if this is a semi colon or a carriage return - // if so, give a new line cursor - if((character == ';') || (charac ter == 13)) usbSerial.printf("\n> "); - - // if not, just print the character - else usbSerial.printf("%c", character); - } - - // reset the flag - scanUSBSerialRxFlag = false; -} -//----------------------------------------------------------------------------- +Shell *usbSerialShell; void setScanUSBSerialRxFlag() { @@ -50,10 +16,10 @@ void initMain() { // increase the baud rate for the USB serial port - usbSerial.baud(115200); + usbSerialShell = new Shell(115200); // send greeting with first cursor - sendHelloWorld(); + usbSerialShell->sendHelloWorld(); // start polling for characters scanTicker.attach(&setScanUSBSerialRxFlag, 0.01); @@ -67,7 +33,10 @@ while(true) { // check the flag - if(scanUSBSerialRxFlag) scanUSBSerialRx(); + if(scanUSBSerialRxFlag) { + usbSerialShell->scanUSBSerialRx(); + scanUSBSerialRxFlag = false; + } // give the main loop some time wait(0.02);