From c959e65edde0b07b80c3e12f177afd938abbdcd6 Mon Sep 17 00:00:00 2001 From: Rocky04 Date: Mon, 7 Aug 2023 21:16:41 +0200 Subject: [PATCH] Fixing wrong callback placement --- src/device/usbd.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/device/usbd.c b/src/device/usbd.c index b4ca63c9c..2daf91d77 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -711,7 +711,16 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const } // switch to new configuration if not zero - if ( cfg_num ) TU_ASSERT( process_set_config(rhport, cfg_num) ); + if ( cfg_num ) + { + 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,16 +973,6 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num) TU_ASSERT(drv_id < TOTAL_DRIVER_COUNT); } - // invoke callback - if (cfg_num) - { - if (tud_mount_cb) tud_mount_cb(); - } - else - { - if (tud_umount_cb) tud_umount_cb(); - } - return true; }