Skip to content

Commit b6fb478

Browse files
committed
Add USBCDC example
1 parent 2d3d761 commit b6fb478

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "mbed.h"
2+
#include "USBCDC.h"
3+
4+
USBCDC cdc;
5+
6+
int main(void) {
7+
8+
while(1)
9+
{
10+
char msg[] = "Hello world\r\n";
11+
cdc.send((uint8_t*)msg, strlen(msg));
12+
wait(1.0);
13+
}
14+
}

0 commit comments

Comments
 (0)