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

Files at this revision

API Documentation at this revision

Comitter:
ajp109
Date:
Sat Nov 21 14:35:38 2020 +0000
Parent:
0:5a0d57dc490b
Commit message:
Initial commit

Changed in this revision

UoY-serial.cpp Show annotated file Show diff for this revision Revisions of this file
UoY-serial.h Show annotated file Show diff for this revision Revisions of this file
UoY-utils.h Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UoY-serial.cpp	Sat Nov 21 14:35:38 2020 +0000
@@ -0,0 +1,13 @@
+#include "stdlib.h"
+#include "mbed.h"
+
+static BufferedSerial *serial_port = new BufferedSerial(USBTX, USBRX, 9600);
+
+FileHandle *mbed::mbed_override_console(int fd) {
+    return serial_port;
+}
+
+void serial_settings(PinName tx, PinName rx, int baud = 9600) {
+    delete serial_port;
+    serial_port = new BufferedSerial(tx, rx, baud);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UoY-serial.h	Sat Nov 21 14:35:38 2020 +0000
@@ -0,0 +1,1 @@
+void serial_settings(PinName tx, PinName rx, int baud = 9600);
--- a/UoY-utils.h	Sat Nov 21 13:35:39 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-#define serial_setup(tx,rx,baud) \
-static BufferedSerial serial_port(tx, rx, baud); \
-FileHandle *mbed::mbed_override_console(int fd) { \
-    return &serial_port; \
-}