USB serial device with Maple Mini board.

Dependencies:   USBDevice_STM32F103 mbed-MapleMini mbed

Building a USB serial device with Maple Mini board

A USB device stack has been developed by mbed in order to provide all the great capabilities of USB. The USBdevice class has been extended by Norimasa Okamoto to support also the NUCLEO-F103RB boards (and others). For more information concerning the stack architecture, visit the USBDevice stack architecture.
The USBSerial class uses the USB interface to emulate a serial port. The Maple Mini board is recognized by the computer as a serial port. This is a great solution to communicate easily between the microcontroller and a computer. The mbed serial port works by default on Mac, Linux and Windows 10, but earlier version of Windows needs a driver. These instructions explain how to setup the mbed Microcontroller to use the USB serial port on Windows 7 and earlier.

NOTE:

If you build a USB serial device with the Maple Mini board then note that for the USB device to work the USB DP pin (PA_12) shall be connected to VCC over a 1.5k resistor (R10). Otherwise the host PC won't recognise the USB device and the USB device library code will hang. All parts are already installed on the board (see in the schematic below) and can be connected/disconnected using a DigitalOut on pin PB_9.

/media/uploads/hudakz/maple_usb.png

In this application, power the Maple Mini board over a USB cable connected to the Mini-B USB connector that you are going to use for the USB serial communication with the connected PC. Once the binary has been downloaded to the board, disconnect and then reconnect the USB cable to the Maple Mini board to start running the program and to get the USB serial connection work.

Committer:
hudakz
Date:
Sun Aug 14 10:02:02 2016 +0000
Revision:
1:dd51a3c8ce18
Parent:
0:d37938a78bc5
Updated.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hudakz 0:d37938a78bc5 1 #include "MapleMini.h"
hudakz 0:d37938a78bc5 2 #include "mbed.h"
hudakz 0:d37938a78bc5 3 #include "USBSerial.h"
hudakz 0:d37938a78bc5 4
hudakz 0:d37938a78bc5 5 DigitalOut myled(LED1);
hudakz 1:dd51a3c8ce18 6 DigitalOut usbEn(PB_9); //Used for connecting/disconnecting the 1k5 resistor to/from the USB DP pin
hudakz 0:d37938a78bc5 7
hudakz 0:d37938a78bc5 8 int main() {
hudakz 0:d37938a78bc5 9 confSysClock(); //Configure system clock (72MHz HSE clock, 48MHz USB clock)
hudakz 1:dd51a3c8ce18 10
hudakz 1:dd51a3c8ce18 11 Serial pc(PA_2, PA_3);
hudakz 1:dd51a3c8ce18 12 USBSerial usbSerial;
hudakz 1:dd51a3c8ce18 13
hudakz 0:d37938a78bc5 14 usbEn = 0; //Keep the on-board 1k5 resistor connected to the USB DP pin
hudakz 0:d37938a78bc5 15
hudakz 0:d37938a78bc5 16 while(1) {
hudakz 0:d37938a78bc5 17 myled = !myled;
hudakz 0:d37938a78bc5 18 pc.printf("I am a serial port\r\n"); // 9600 bit/s
hudakz 0:d37938a78bc5 19 usbSerial.printf("I am a USB serial port\r\n"); // 12 Mbit/s (USB full-speed)
hudakz 0:d37938a78bc5 20 wait_ms(1000);
hudakz 0:d37938a78bc5 21 }
hudakz 0:d37938a78bc5 22 }