Clear _usbd_dev prior to driver reset.

This commit is contained in:
HiFiPhile 2024-05-08 14:07:32 +02:00 committed by hathach
parent 60b3d14d19
commit a1fd43ebaf
No known key found for this signature in database
GPG Key ID: 26FAB84F615C3C52

View File

@ -495,15 +495,16 @@ bool tud_deinit(uint8_t rhport) {
}
static void configuration_reset(uint8_t rhport) {
// Clear mounted status first to ensure tud_ready() return false before driver clean up.
tu_varclr(&_usbd_dev);
memset(_usbd_dev.itf2drv, DRVID_INVALID, sizeof(_usbd_dev.itf2drv)); // invalid mapping
memset(_usbd_dev.ep2drv, DRVID_INVALID, sizeof(_usbd_dev.ep2drv)); // invalid mapping
for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++) {
usbd_class_driver_t const* driver = get_driver(i);
TU_ASSERT(driver,);
driver->reset(rhport);
}
tu_varclr(&_usbd_dev);
memset(_usbd_dev.itf2drv, DRVID_INVALID, sizeof(_usbd_dev.itf2drv)); // invalid mapping
memset(_usbd_dev.ep2drv, DRVID_INVALID, sizeof(_usbd_dev.ep2drv)); // invalid mapping
}
static void usbd_reset(uint8_t rhport) {