Charles Tritt
/
SerialEcho_UC
Echos ASCII message converted to uppercase. Uses toupper function from standard C library.
main.cpp@1:ea72a608382f, 2017-11-09 (annotated)
- Committer:
- CSTritt
- Date:
- Thu Nov 09 15:21:35 2017 +0000
- Revision:
- 1:ea72a608382f
- Parent:
- 0:2f9e67d4c561
- Child:
- 2:e53dfe50252a
Initial version.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CSTritt | 1:ea72a608382f | 1 | /* |
CSTritt | 1:ea72a608382f | 2 | Project: SerialRelay |
CSTritt | 1:ea72a608382f | 3 | File: main.cpp |
CSTritt | 1:ea72a608382f | 4 | Created by: Dr. C. S. Tritt |
CSTritt | 1:ea72a608382f | 5 | Last revised: 11/8/17 |
CSTritt | 1:ea72a608382f | 6 | |
CSTritt | 1:ea72a608382f | 7 | Relays serial data from PC to Nucleo Serial3 (PC_10 for TX, PC_11 for RX). |
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 | 0:2f9e67d4c561 | 16 | //------------------------------------ |
CSTritt | 1:ea72a608382f | 17 | |
CSTritt | 0:2f9e67d4c561 | 18 | //------------------------------------ |
CSTritt | 0:2f9e67d4c561 | 19 | |
CSTritt | 1:ea72a608382f | 20 | Serial pc(USBTX, USBRX, 9600); // Standard to PC via USB channel. |
CSTritt | 1:ea72a608382f | 21 | Serial bc(PC_10, PC_11, 9600); // Serial3. Pins at top of left Morphio header. |
CSTritt | 0:2f9e67d4c561 | 22 | |
CSTritt | 1:ea72a608382f | 23 | DigitalOut actLED(LED1); // Activity toggle. |
CSTritt | 0:2f9e67d4c561 | 24 | |
CSTritt | 0:2f9e67d4c561 | 25 | int main() |
CSTritt | 0:2f9e67d4c561 | 26 | { |
CSTritt | 1:ea72a608382f | 27 | while (true) { |
CSTritt | 1:ea72a608382f | 28 | if (pc.readable()) { |
CSTritt | 1:ea72a608382f | 29 | char character = (char) pc.getc(); |
CSTritt | 1:ea72a608382f | 30 | //pc.putc(character); |
CSTritt | 1:ea72a608382f | 31 | bc.putc(character); |
CSTritt | 1:ea72a608382f | 32 | actLED = !actLED; |
CSTritt | 1:ea72a608382f | 33 | } |
CSTritt | 1:ea72a608382f | 34 | if (bc.readable()) { |
CSTritt | 1:ea72a608382f | 35 | char character = (char) bc.getc(); |
CSTritt | 1:ea72a608382f | 36 | //bc.putc(character); |
CSTritt | 1:ea72a608382f | 37 | pc.putc(character); |
CSTritt | 1:ea72a608382f | 38 | actLED = !actLED; |
CSTritt | 1:ea72a608382f | 39 | } |
CSTritt | 0:2f9e67d4c561 | 40 | } |
CSTritt | 0:2f9e67d4c561 | 41 | } |