USB Serial application

Fork of USBSerial_HelloWorld by Samuel Mokrani

Committer:
Zaitsev
Date:
Tue Jan 10 20:42:26 2017 +0000
Revision:
10:41552d038a69
Parent:
9:d88699a0905a
Child:
11:b3f2a8bdac4d
USB Serial bi-directional bridge

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 7:5e693654d5b4 1 #include "mbed.h"
Zaitsev 10:41552d038a69 2
samux 7:5e693654d5b4 3 #include "USBSerial.h"
Zaitsev 10:41552d038a69 4
Zaitsev 10:41552d038a69 5 DigitalOut myled(LED1);
Zaitsev 10:41552d038a69 6 void confSysClock();
Zaitsev 10:41552d038a69 7
Zaitsev 10:41552d038a69 8 int main() {
Zaitsev 10:41552d038a69 9 //confSysClock(); //Configure system clock (72MHz HSE clock, 48MHz USB clock)
Zaitsev 10:41552d038a69 10 //SYSTEM CLOCK changed in stm32f4xx_hal.c
Zaitsev 10:41552d038a69 11 Serial pc(PA_2, PA_3); // you may substitute any buffered serial driver here
Zaitsev 10:41552d038a69 12 USBSerial usbSerial;
Zaitsev 10:41552d038a69 13
Zaitsev 10:41552d038a69 14 while(1) {
Zaitsev 10:41552d038a69 15
Zaitsev 10:41552d038a69 16 myled = !myled;
Zaitsev 10:41552d038a69 17 if(pc.readable()) //if there is any character to read from pc
Zaitsev 10:41552d038a69 18 {
Zaitsev 10:41552d038a69 19 usbSerial.putc(pc.getc()); //send it over to usbSerial
Zaitsev 10:41552d038a69 20 }
Zaitsev 10:41552d038a69 21 if(usbSerial.readable()) //if there is any character to read from usbSerial
Zaitsev 10:41552d038a69 22 {
Zaitsev 10:41552d038a69 23 pc.putc(usbSerial.getc()); //send it over to pc
Zaitsev 10:41552d038a69 24 }
samux 7:5e693654d5b4 25 }
samux 7:5e693654d5b4 26 }