USB Serial application

Fork of USBSerial_HelloWorld by Samuel Mokrani

main.cpp

Committer:
Zaitsev
Date:
2017-01-10
Revision:
10:41552d038a69
Parent:
9:d88699a0905a
Child:
11:b3f2a8bdac4d

File content as of revision 10:41552d038a69:

#include "mbed.h"

#include "USBSerial.h"

DigitalOut  myled(LED1);
void confSysClock();

int main() {
    //confSysClock();     //Configure system clock (72MHz HSE clock, 48MHz USB clock)
    //SYSTEM CLOCK changed in stm32f4xx_hal.c
    Serial    pc(PA_2, PA_3);  // you may substitute any buffered serial driver here
    USBSerial usbSerial;
    
    while(1) {
        
        myled = !myled;
        if(pc.readable()) //if there is any character to read from pc
        {
           usbSerial.putc(pc.getc()); //send it over to usbSerial
        }
        if(usbSerial.readable()) //if there is any character to read from usbSerial
        {
           pc.putc(usbSerial.getc()); //send it over to pc
        }
    }
}