-
enable in
STM32CubeMXinPinout & ConfigurationunderConnectivitythe periphery forUSB_OTG_FSasDevice only.- Make sure that usb global interrupt under
NVIC Settingsis enabled
- Make sure that usb global interrupt under
-
add
tinyUSBas submodule to your project -
add the folder
tinyUSB/srcto your build sources- exclude
tinyUSB/src/portable/stfrom your build, instead usetinyUSB/src/portable/synopsys
- exclude
-
add the following lines to your
main.h#include "tusb_config.h" #include "tusb.h"
-
add
CFG_TUSB_MCU=OPT_MCU_STM32F7as preprocessor macros to your project -
add
tinyUSBinterrupt handler with the following code toOTG_FS_IRQHandlerinstm32f7xx_it.c, beforeHAL_PCD_IRQHandleris calledtud_int_handler(BOARD_TUD_RHPORT); return;
-
add the following code after hal initalisation was called in
mainfunctiontud_init(BOARD_TUD_RHPORT);
-
call
tud_task()in each loop iteration inmainfunction. -
add your own
tusb_config.handusb_description.cto your project
- enable freeRTOS in
STM32CubeMX - add task for
tinyUSB - define
CFG_TUSB_OSasOPT_OS_FREERTOSintusb_config.h