Enzo Grimeau
/
GPS_V2
Récupération de trame NMEA
Diff: main.cpp
- Revision:
- 8:23fca4edc6b9
- Parent:
- 7:37ea12f2b18f
- Child:
- 9:a9dfb95b5d8a
--- 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); } } +