Skip to content

Commit

Permalink
Proper handle for configuration reset
Browse files Browse the repository at this point in the history
  • Loading branch information
RockyZeroFour committed Feb 21, 2024
1 parent 476994e commit e825b7f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/device/usbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,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;
Expand Down Expand Up @@ -956,9 +966,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;
}

Expand Down

0 comments on commit e825b7f

Please sign in to comment.