Skip to content

Commit 601341e

Browse files
committed
Add USBCDC example
1 parent 2d3d761 commit 601341e

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

APIs_USB/USBCDC/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## USBCDC example
2+
3+
The example sends string in the loop using an emulated serial port over USB.
4+
5+
1. Flash the board, and ensure the target's auxiliary USB is plugged into the PC.
6+
2. Open serial console (select associated COM port, transmission speed: 9600 bps).
7+
3. Reset the target.
8+
4. "Hello world" string should appear in the loop on the serial console in the 1-second delays.
9+
10+
**Note:** On Windows you can check the associated COM port in the Device Manager (USB Serial Device).
11+
**Note:** If you want printf functionality, please see the USBSerial class.

APIs_USB/USBCDC/main.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "mbed.h"
2+
#include "USBSerial.h"
3+
4+
//Virtual serial port over USB
5+
USBSerial serial;
6+
7+
int main(void) {
8+
while(1)
9+
{
10+
serial.printf("I am a virtual serial port\r\n");
11+
wait(1.0);
12+
}
13+
}

0 commit comments

Comments
 (0)