Charles Tritt
/
SerialEcho_UC
Echos ASCII message converted to uppercase. Uses toupper function from standard C library.
main.cpp@2:e53dfe50252a, 2019-01-17 (annotated)
- Committer:
- CSTritt
- Date:
- Thu Jan 17 19:57:50 2019 +0000
- Revision:
- 2:e53dfe50252a
- Parent:
- 1:ea72a608382f
- Child:
- 3:041d6aaa4a7b
Initial version. Echos what it receives.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CSTritt | 1:ea72a608382f | 1 | /* |
CSTritt | 2:e53dfe50252a | 2 | Project: SerialEcho |
CSTritt | 1:ea72a608382f | 3 | File: main.cpp |
CSTritt | 1:ea72a608382f | 4 | Created by: Dr. C. S. Tritt |
CSTritt | 2:e53dfe50252a | 5 | Last revised: 1/17/19 |
CSTritt | 1:ea72a608382f | 6 | |
CSTritt | 2:e53dfe50252a | 7 | Receives serial data from PC to and echos it back, character for character. |
CSTritt | 1:ea72a608382f | 8 | |
CSTritt | 1:ea72a608382f | 9 | Tera Term configurations |
CSTritt | 1:ea72a608382f | 10 | Terminal - New-line, Receive LF, Transmit LF |
CSTritt | 1:ea72a608382f | 11 | Serial port - Data 8 bit, Parity none, Stop 1 bit, Flow control none. |
CSTritt | 1:ea72a608382f | 12 | Baud as specified below. |
CSTritt | 1:ea72a608382f | 13 | */ |
CSTritt | 0:2f9e67d4c561 | 14 | #include "mbed.h" |
CSTritt | 0:2f9e67d4c561 | 15 | |
CSTritt | 1:ea72a608382f | 16 | Serial pc(USBTX, USBRX, 9600); // Standard to PC via USB channel. |
CSTritt | 0:2f9e67d4c561 | 17 | |
CSTritt | 1:ea72a608382f | 18 | DigitalOut actLED(LED1); // Activity toggle. |
CSTritt | 0:2f9e67d4c561 | 19 | |
CSTritt | 0:2f9e67d4c561 | 20 | int main() |
CSTritt | 0:2f9e67d4c561 | 21 | { |
CSTritt | 1:ea72a608382f | 22 | while (true) { |
CSTritt | 1:ea72a608382f | 23 | if (pc.readable()) { |
CSTritt | 1:ea72a608382f | 24 | char character = (char) pc.getc(); |
CSTritt | 1:ea72a608382f | 25 | //pc.putc(character); |
CSTritt | 1:ea72a608382f | 26 | pc.putc(character); |
CSTritt | 1:ea72a608382f | 27 | actLED = !actLED; |
CSTritt | 1:ea72a608382f | 28 | } |
CSTritt | 0:2f9e67d4c561 | 29 | } |
CSTritt | 0:2f9e67d4c561 | 30 | } |