How to detect USB MSC device connection and disconnection in stm32H743
hi,
I have just implemented USB MSC device and file system in my stm32h743. it work properly, as I connect to PC it shows the device. my code logic is, i will write configuration file to file system and and controller will read that file. this is happening in right manner.
problem is, whenever there is new config file in filesystem my controller should know it.
this is happen only when the device is disconnected from host. then controller will do whatever it want.
for that there is two function in usbd_conf.c file
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
/* Inform USB library that core enters in suspend Mode. */
USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData);
__HAL_PCD_GATE_PHYCLOCK(hpcd);
/* Enter in STOP mode. */
/* USER CODE BEGIN 2 */
if (hpcd->Init.low_power_enable)
{
/* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */
SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
}
flag = 1;
//HAL_Delay(1000);
/* USER CODE END 2 */
}but this function detect the USb at the time connection and disconnection.
Is any thing I have to do my side to detect at once . please guide me.
thanking you.
