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:
- 8:23fca4edc6b9
- Parent:
- 7:37ea12f2b18f
- Child:
- 9:a9dfb95b5d8a
diff -r 37ea12f2b18f -r 23fca4edc6b9 main.cpp
--- a/main.cpp Sun Oct 25 16:47:59 2020 +0000
+++ b/main.cpp Sun Nov 22 15:04:32 2020 +0000
@@ -1,23 +1,31 @@
#include "mbed.h"
-//
-// test led
+// Echo
+// lien serie via USB avec Terarerm
// GR 2020
// Universite Paris-Saclay - IUT Cachan
//
//
-#define TEMPO 0.5
-Serial pc(USBTX, USBRX);
-DigitalOut led(PA_5); //LED1
-
+RawSerial pc_raw(USBTX, USBRX); // ou SERIAL-TX, SERIAL_RX ou PA_2,PA_3
+DigitalOut ledB(D8);
+void reception_symbole(void);
int main()
{
- pc.printf("LED clignotante\r\n");
- led=1;
+
+ pc_raw.baud(115200);
+ pc_raw.attach(&reception_symbole);
+ pc_raw.printf("Echo test\r\n");
+ ledB=0;
while(1) {
- led = 0; // OFF
- wait(TEMPO);
- led = 1; // ON
- wait(TEMPO);
+ }
+}
+void reception_symbole(void)
+{
+ unsigned char c;
+ if(pc_raw.readable()) {
+ ledB=!ledB;
+ c=pc_raw.getc();
+ pc_raw.putc(c);
}
}
+