Ports serie USB trensparent

main.cpp

Committer:
schnf30
Date:
2022-05-18
Revision:
0:0184b799af90

File content as of revision 0:0184b799af90:

#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);
    }
}