STM32F103 USB CDC CMSIS
STM32F103 USB CDC CMSIS provires a simple low weight firmware for STM32F1 serie to implement Virtual Com Port. Current implementation create Virtual Com Port with next settings: 115200, 0, none, 8, but you can change these settings as you want.
usblib.c
and usblib.h
to your project.USBLIB_Init();
to enable USB and make initial configuration of USB registers. Please note - USBLIB_Init();
will trigget USB RESET sequence.RemoteSwitchHUB.inf
to install a default Windows driver. After installation you will see new COM port named RemoteSwitch HUB
(If you want to change this name you need to edit it in usblib.c
and inf
files).void uUSBLIB_LineStateHandler(USBLIB_WByte LineState)
in your code to handle line state. See main.c
for example.
NOTE: you can't send any data to host when port is closed! To controll when port is opened use this condition:if (LineState.L) { //App connected to the virtual port
USBLIB_Transmit((uint16_t *)"Welcome to the club!\r\n", 22);
}
void uUSBLIB_DataReceivedHandler(uint16_t *Data, uint16_t Length)
in your code to accept data from host. See main.c
f.e.Code well tested on Windows7, MacOS 10.13 (High Sierra) and Raspbian OS.