diff options
| author | Ha Thach <[email protected]> | 2023-08-09 20:48:26 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-08-09 20:48:26 +0700 |
| commit | 92457ec99f1690b772ef9fa6b348256701c7fcf7 (patch) | |
| tree | a2ecde3f6562e57a1ceba382beb2b0b382bd14f9 /src | |
| parent | 04f0cd5c801e5e1575bbc5c714ac9649053af683 (diff) | |
| parent | 9602c06f8d52212b55b02533e188e91b7192c080 (diff) | |
Merge pull request #2202 from Rocky04/patch-4
Invoke unmounted state on configuration reset
Diffstat (limited to 'src')
| -rw-r--r-- | src/device/usbd.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c index 9429cf664..156b92ce1 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -710,8 +710,18 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const _usbd_dev.speed = speed; // restore speed } - // switch to new configuration if not zero - if ( cfg_num ) TU_ASSERT( process_set_config(rhport, cfg_num) ); + // Handle the new configuration and execute the corresponding callback + if ( cfg_num ) + { + // switch to new configuration if not zero + TU_ASSERT( process_set_config(rhport, cfg_num) ); + + if ( tud_mount_cb ) tud_mount_cb(); + } + else + { + if ( tud_umount_cb ) tud_umount_cb(); + } } _usbd_dev.cfg_num = cfg_num; @@ -964,9 +974,6 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num) TU_ASSERT(drv_id < TOTAL_DRIVER_COUNT); } - // invoke callback - if (tud_mount_cb) tud_mount_cb(); - return true; } |
