Reputation: 1
I have encountered a problem in my project, I need to port the usbhost code framework generated by stm32cubemx to gd32, without modification, it can detect the insertion of the u-disk, but there will be a problem when executing the write operation, I don't know if there is any porting success?(p.s. the chip model I used is gd32f107vc and then the corresponding stm32 model is stm32f107vc)
I looked at the manuals for both chips and found that most of their registers are pretty much the same, it's the small parts of them that differ, so I didn't want to use the official gd32 usb library to execute it, as it might involve other issues
Upvotes: 0
Views: 61
Reputation: 159
In the usb_host.c change this void MX_USB_HOST_Init(void) to this code:
void MX_USB_HOST_Init(void)
{
/* USER CODE BEGIN USB_HOST_Init_PreTreatment */
/* USER CODE END USB_HOST_Init_PreTreatment */
/* Init host Library, add supported class and start the library. */
if (USBH_Init(&hUsbHostFS, USBH_UserProcess, HOST_FS) != USBH_OK)
{
Error_Handler();
}
if (USBH_RegisterClass(&hUsbHostFS, USBH_MSC_CLASS) != USBH_OK)
{
Error_Handler();
}
if (USBH_Start(&hUsbHostFS) != USBH_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USB_HOST_Init_PostTreatment */
(void)USBH_LL_ResetPort(&hUsbHostFS);
USBH_Stop(&hUsbHostFS);
if (USBH_Start(&hUsbHostFS) != USBH_OK)
{
Error_Handler();
}
/* USER CODE END USB_HOST_Init_PostTreatment */
}
Upvotes: 0