Difference between revisions of "Mbed USB client"
From emboxit
m (1 revision) |
|
(No difference)
|
Latest revision as of 16:51, 11 September 2015
Suga koubou libraries and programs
- USB client (p31,p32) as a virtual serial and flash drive at the same time
- Suga koubou mbed Notebook
- Suga koubou USB_CDC
mbed handbook
- Driver required on Windows!
USBSerial Hello World! #include "mbed.h" #include "USBSerial.h" //Virtual serial port over USB USBSerial serial; int main(void) { while(1) { serial.printf("I am a virtual serial port\r\n"); wait(1); } }
USBSerial echo #include "mbed.h" #include "USBSerial.h" //Virtual serial port over USB USBSerial serial; Serial pc(USBTX, USBRX); int main(void) { uint8_t buf[128]; while(1) { serial.scanf("%s", buf); serial.printf("recv: %s", buf); pc.printf("recv: %s\r\n", buf); } }
comments
The USBSerial constructor waits until the device is connected. So if the cable is not plugged, the mbed will hang. You can see if the connection is working in the device manager on windows. I think that the best way to check the usb connection is USBMouse. If the cursor is moving on your screen, it means that the usb connection is correct.