Using the stock CDC drivers

mainRawCDC.c contains a minimal amount of code to configure the MCU hardware and USB device stack. It will allow the MCU to enumerate over USB as a virtual COM port when a micro-USB cable is plugged into CN1 (and goes to a USB host such as a PC) and power is applied through CN13. It will attempt to send two messages over USB: test and message:

  1. The USB stack is initialized by using the MX_USB_Device_Init() function after the hardware is fully initialized:
int main(void){  HWInit();=  MX_USB_DEVICE_Init();
  1. There is a single task that outputs two strings over USB, with a forced 100 tick delay after the second transmission using a naive call to usbd_cdc_if.cCDC_Transmit_FS:
void usbPrintOutTask( void* NotUsed) ...

Get Hands-On RTOS with Microcontrollers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.