2019-07-01 11:33 PM
Hello,
I'm trying to use the USBH library in my project by taking the corresponding chunks of code from the USB_Host Application example present in the STM32Cube. However, I must miss an important part because the USB_UserProcess is never entered. I must add that I'm using FreeRTOS and that I call the USBH_Process(&hUSBHost) function from within a task but it shouldn't alter the good functioning of the code normally. So, to recap briefly : I've declared two global variables :
USBH_HandleTypeDef hUSBHost;
char USBDISKPath[4];
Then, in the main function, before starting the scheduler or creating any FreeRTOS tasks, I've these three lines :
USBH_Init(&hUSBHost, USBH_UserProcess, 0);
USBH_RegisterClass(&hUSBHost, USBH_MSC_CLASS);
USBH_Start(&hUSBHost);
Then, I create a very simple task before starting the scheduler
xUSB = xTaskCreate(USB_Task, "USB TASK", 500, NULL, 1, NULL);
My USB task just contains a delay and the USBH_Process:
void USB_Task(void* arg)
{
while(1){
vTaskDelay(200);
USBH_Process(&hUSBHost);
}
}
And here's what's inside the USBH_UserProcess function:
static void USBH_UserProcess(USBH_HandleTypeDef * phost, uint8_t id)
{
HAL_GPIO_WritePin(GPIOJ, LD_USER2_Pin, GPIO_PIN_SET);
}
So normally, when connecting or disconnecting a USB stick, the state of the LED should change but nothing happens. The function USBH_UserProcess is never entered by the program, although the USBH_Process function is called "every 200ms".
What am I doing wrong? What am I missing? It should be easy but I can't seem to figure out why it doesn't work.
Thanks in advance for your help.