Echos ASCII message converted to uppercase. Uses toupper function from standard C library.

Dependencies:   mbed

Committer:
CSTritt
Date:
Sat Jan 19 19:49:17 2019 +0000
Revision:
3:041d6aaa4a7b
Parent:
2:e53dfe50252a
Child:
4:0ed7a3594910
Cleaned up code and added additional comments.

Who changed what in which revision?

UserRevisionLine numberNew 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 3:041d6aaa4a7b 5 Last revised: 1/17/19 (v. 1.0)
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 3:041d6aaa4a7b 18 DigitalOut actLED(LED1); // Activity LED.
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 3:041d6aaa4a7b 24 char character = (char) pc.getc(); // Get a char from the PC.
CSTritt 3:041d6aaa4a7b 25 pc.putc(character); // Send it back to the PC.
CSTritt 3:041d6aaa4a7b 26 actLED = !actLED; // Toggle the activity LED.
CSTritt 1:ea72a608382f 27 }
CSTritt 0:2f9e67d4c561 28 }
CSTritt 0:2f9e67d4c561 29 }