cancel
Showing results for 
Search instead for 
Did you mean: 

How to call MX_USB_HOST_Process() from freeRTOS Task

LMorr.3
Senior II

Update: I found a timer1 conflict with the USB_OTG so I do think this will be resolved once I fix the timer1. I'm learning how to use STM32CubeIDE with freeRTOS to program my STM32F407 DISCO board. From my understanding, I have to call MX_USB_HOST_Process() to keep my debugger/IDE updated. Since the main loop in my main.c file is no longer called and superseded by freeRTOS, I created a defaultTask who's sole job is to call 'MX_USB_HOST_Process()'. I created a default_task.h and default_task.c file and include the usb_host.h file however I get an 'undefined reference error' when calling 'MX_USB_HOST_Process();.

Is there an example for using STM32CubeIDE with freeRTOS tasks instead of a main.c loop?

I included the default_task.c file

2 REPLIES 2

Hello @LMorr.3​ 

You can refer to the following example provided under the F4 Firmware Package:

  • Path: Projects\STM32469I_EVAL\Applications\USB_Host\HID_RTOS

I hope this helps.

BeST Regards,

Walid

CCend.2
Associate III

You do not need to manually call MX_USB_HOST_Process() when using RTOS. As long as you enable USBH_USE_OS under Middleware->USB_HOST in the .ioc file, the automatic code generation should take care of it for you.


_legacyfs_online_stmicro_images_0693W00000bkDJpQAM.pngIn my case, it inserted a MX_USB_HOST_Init() call into my first task. All I had to do was add an osDelay() in the for loop and USB worked just fine. I don't know where MX_USB_HOST_Process() is being called, but it must be somewhere hidden in the RTOS code.