How to disable USB Mass storage at runtime.
I to all,
I have a project where an STM32F013RTC use an SD card.
At run time the SD is share with FAT_FS or it is used as USB mass storage device, but not at the same time.
I need to disable USB module.
The configuration is made from CubeMX, so I have the function MX_USB_DEVICE_Init() to enable and configure USB.
void MX_USB_DEVICE_Init(void)
{
/* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
/* USER CODE END USB_DEVICE_Init_PreTreatment */
/* Init Device Library, add supported class and start the library. */
if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK)
{
Error_Handler();
}
if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_MSC) != USBD_OK)
{
Error_Handler();
}
if (USBD_MSC_RegisterStorage(&hUsbDeviceFS, &USBD_Storage_Interface_fops_FS) != USBD_OK)
{
Error_Handler();
}
if (USBD_Start(&hUsbDeviceFS) != USBD_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
/* USER CODE END USB_DEVICE_Init_PostTreatment */
}I wrote a function to disable USB:
void MX_USB_DEVICE_DeInit(void){
USBD_DeInit(&hUsbDeviceFS);
}But this cause an Hard Fault reset.
Thre is an HAL function to disable USB module ?
