Skip to content

Commit

Permalink
Save setup_count on bus reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
HiFiPhile committed May 8, 2024
1 parent 238a740 commit d4b35e5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/device/usbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,13 @@ bool tud_deinit(uint8_t rhport) {
}

static void configuration_reset(uint8_t rhport) {
// Save setup_count for restore
uint8_t setup_count = _usbd_dev.setup_count;
// 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
_usbd_dev.setup_count = setup_count;

for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++) {
usbd_class_driver_t const* driver = get_driver(i);
Expand Down

0 comments on commit d4b35e5

Please sign in to comment.