schneider françois
/
0-SimXXXXl-echo-L432kc
Ports serie USB trensparent
Diff: main.cpp
- Revision:
- 0:0184b799af90
--- /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); + } +}