Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:0d96af962118
diff -r 000000000000 -r 0d96af962118 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sun May 22 19:23:55 2022 +0000
@@ -0,0 +1,44 @@
+// ======================================================================
+
+#include "mbed.h"
+
+RawSerial PC(USBTX, USBRX); // PC = (USBTX=TX, USBRX=RX)
+RawSerial ESP(D1, D0); // ESP = (D1=TX, D0=RX)
+
+/// ======================================================================
+// ISR for redirecting PC RX to ESP TX
+
+void ISR_PC_to_ESP()
+{
+ while(PC.readable()) {
+ ESP.putc(PC.getc());
+ }
+}
+
+// ======================================================================
+// ISR for redirecting ESP RX to PC TX
+
+void ISR_ESP_to_PC()
+{
+ while(ESP.readable()) {
+ PC.putc(ESP.getc());
+ }
+}
+
+// ======================================================================
+// Main thread
+
+int main()
+{
+ PC.baud(115200);
+ ESP.baud(115200);
+
+ PC.attach(&ISR_PC_to_ESP, Serial::RxIrq);
+ ESP.attach(&ISR_ESP_to_PC, Serial::RxIrq);
+
+ while(1) {
+ sleep();
+ }
+}
+
+// ======================================================================
\ No newline at end of file