cancel
Showing results for 
Search instead for 
Did you mean: 

USB Host Library for STM32F4

brett
Associate II
Posted on March 29, 2014 at 15:38

Hi,

I'm using the new version of the USB Host library that comes with STM Cube, but I'm having some difficulty as the only documentation I can find is for the old library. Does anyone know if there is any new documentation? I can't find any and there seems to be some substantial differences. For example, previously I could initialize the host with:

void
USBH_Init (USB_OTG_CORE_HANDLE *pdev, USB_OTG_CORE_ID_TypeDef coreID,USBH_HOST *phost, USBH_Class_cb_TypeDef *class_cb, USBH_Usr_cb_TypeDef *usr_cb);

While the new init function looks very different:

USBH_StatusTypeDef USBH_Init(USBH_HandleTypeDef *phost, 
void
(*pUsrFunc)(USBH_HandleTypeDef *phost, uint8_t ), uint8_t id)

So it's not clear to me how the user call back works. Am I supposed to use just one function, and switch on the ID (the uint8_t argument in the pointer to the user function above)? The list of 5 possible IDs doesn't directly correspond to the previous four user callback functions that had to be implemented either. Any help appreciated Bert #stm32 #usb #library #otg
1 REPLY 1
tsuneo
Senior
Posted on March 29, 2014 at 19:42

> So it's not clear to me how the user call back works.

\STM32Cube_FW_F4_V1.1.0\Projects\STM32F4-Discovery\Applications\FatFs\FatFs_USBDisk\Src\main.c (modified)
static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id)
{ 
switch(id)
{
/* end of device basic enumeration */
case HOST_USER_SELECT_CONFIGURATION:
break;
/* a matched class driver is picked up from the class list (TPL) */
case HOST_USER_CLASS_SELECTED:
break;
/* class-specific initialization finishes */
case HOST_USER_CLASS_ACTIVE:
Appli_state = APPLICATION_START;
break;
/* USB Host connexion event */
case HOST_USER_CONNECTION:
break;
/* USB Host disconnexion event */
case HOST_USER_DISCONNECTION:
Appli_state = APPLICATION_IDLE;
BSP_LED_Off(LED4);
BSP_LED_Off(LED5); 
f_mount(NULL, (TCHAR const*)'''', 0); 
break;
default:
break;
}
}

Tsuneo