Ports serie USB trensparent

Files at this revision

API Documentation at this revision

Comitter:
schnf30
Date:
Wed May 18 07:48:25 2022 +0000
Commit message:
Serie transparent entre USB et Port serie

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 0184b799af90 .gitignore
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Wed May 18 07:48:25 2022 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
diff -r 000000000000 -r 0184b799af90 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 18 07:48:25 2022 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "platform/mbed_thread.h"
+// Blinking rate in milliseconds
+#define BLINKING_RATE_MS 500
+RawSerial pc(USBTX,USBRX);
+RawSerial SimXXXX (PA_9,PA_10);
+DigitalOut SimXXXXreset (PA_12);
+
+void SimXXXXreceive()
+{
+    if (SimXXXX.readable()) pc.putc(SimXXXX.getc());
+}
+void pcreceive()
+{
+    if (pc.readable()) SimXXXX.putc(pc.getc());
+}
+int main()
+{
+    SimXXXX.baud(115200);
+    pc.baud(921600);
+    pc.printf("je commence\r\n");
+    pc.printf("reset\r\n");
+    SimXXXXreset.write(0);
+    wait(0.2);
+    SimXXXXreset.write(1);
+    wait(3);
+    pc.printf("reset termine\r\n");
+    SimXXXX.attach(&SimXXXXreceive, RawSerial::RxIrq);
+    pc.attach(&pcreceive, RawSerial::RxIrq);
+    pc.printf("tapez at pour synchroniser la frequence d'horloge\r\n");
+    DigitalOut led(LED1);
+
+    while (true) {
+        led = !led;
+        thread_sleep_for(BLINKING_RATE_MS);
+    }
+}
diff -r 000000000000 -r 0184b799af90 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Wed May 18 07:48:25 2022 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9