/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_FATFS_Init();
MX_USB_HOST_Init();
/* USER CODE BEGIN 2 */
HAL_GPIO_WritePin(GPIOH, GPIO_PIN_5, GPIO_PIN_RESET);//enable usb VBUS
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
MX_USB_HOST_Process();
/* USER CODE BEGIN 3 */
if (pre_state != Appli_state)
{
switch(Appli_state)
{
case APPLICATION_DISCONNECT: //USB flash disk remove
/* Register the file system object to the FatFs module */
if(f_mount(NULL, "", 0) != FR_OK)
{
USBH_UsrLog("ERROR : Cannot exit FatFs! \n");
}
break;
case APPLICATION_READY: //USB flash disk plugin
/* Open or create a log file and ready to append */
if(f_mount(&fs, "", 0) != FR_OK)
{
break;
}
break;
default:
break;
}
}
pre_state = Appli_state;
}
/* USER CODE END 3 */