Serial override, enabling a simple interface onto the mbed stdout redirect. Intended for Stage 1 students in the Department of Electronic Engineering at the University of York
Dependents: UoY-32C-lab2-start UoY-32C-lab7 UoY-32C-lab7-class UoY-32C-lab8-threads ... more
UoY-serial.cpp@1:a86a8c72aca6, 2020-11-21 (annotated)
- Committer:
- ajp109
- Date:
- Sat Nov 21 14:35:38 2020 +0000
- Revision:
- 1:a86a8c72aca6
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ajp109 | 1:a86a8c72aca6 | 1 | #include "stdlib.h" |
ajp109 | 1:a86a8c72aca6 | 2 | #include "mbed.h" |
ajp109 | 1:a86a8c72aca6 | 3 | |
ajp109 | 1:a86a8c72aca6 | 4 | static BufferedSerial *serial_port = new BufferedSerial(USBTX, USBRX, 9600); |
ajp109 | 1:a86a8c72aca6 | 5 | |
ajp109 | 1:a86a8c72aca6 | 6 | FileHandle *mbed::mbed_override_console(int fd) { |
ajp109 | 1:a86a8c72aca6 | 7 | return serial_port; |
ajp109 | 1:a86a8c72aca6 | 8 | } |
ajp109 | 1:a86a8c72aca6 | 9 | |
ajp109 | 1:a86a8c72aca6 | 10 | void serial_settings(PinName tx, PinName rx, int baud = 9600) { |
ajp109 | 1:a86a8c72aca6 | 11 | delete serial_port; |
ajp109 | 1:a86a8c72aca6 | 12 | serial_port = new BufferedSerial(tx, rx, baud); |
ajp109 | 1:a86a8c72aca6 | 13 | } |