mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-26 08:37:16 +00:00
Fix bug during initialization of DFU Mode
This commit is contained in:
parent
c5b8ef1529
commit
fdc91f8d2c
@ -67,7 +67,7 @@ static bool dfu_mode_state_machine(uint8_t rhport, tusb_control_request_t const
|
||||
//--------------------------------------------------------------------+
|
||||
void dfu_mode_init(void)
|
||||
{
|
||||
_dfu_state_ctx.state = DFU_IDLE;
|
||||
_dfu_state_ctx.state = APP_DETACH; // After init, reset will occur. We want to be in APP_DETACH to move to DFU_IDLE
|
||||
_dfu_state_ctx.status = DFU_STATUS_OK;
|
||||
_dfu_state_ctx.attrs = tud_dfu_mode_init_attrs_cb();
|
||||
_dfu_state_ctx.blk_transfer_in_proc = false;
|
||||
@ -79,31 +79,36 @@ void dfu_mode_init(void)
|
||||
|
||||
void dfu_mode_reset(uint8_t rhport)
|
||||
{
|
||||
if ( tud_dfu_mode_usb_reset_cb )
|
||||
if (_dfu_state_ctx.state == APP_DETACH)
|
||||
{
|
||||
tud_dfu_mode_usb_reset_cb(rhport, &_dfu_state_ctx.state);
|
||||
_dfu_state_ctx.state = DFU_IDLE;
|
||||
} else {
|
||||
switch (_dfu_state_ctx.state)
|
||||
if ( tud_dfu_mode_usb_reset_cb )
|
||||
{
|
||||
case DFU_IDLE:
|
||||
case DFU_DNLOAD_SYNC:
|
||||
case DFU_DNBUSY:
|
||||
case DFU_DNLOAD_IDLE:
|
||||
case DFU_MANIFEST_SYNC:
|
||||
case DFU_MANIFEST:
|
||||
case DFU_MANIFEST_WAIT_RESET:
|
||||
case DFU_UPLOAD_IDLE:
|
||||
tud_dfu_mode_usb_reset_cb(rhport, &_dfu_state_ctx.state);
|
||||
} else {
|
||||
switch (_dfu_state_ctx.state)
|
||||
{
|
||||
_dfu_state_ctx.state = (tud_dfu_mode_firmware_valid_check_cb()) ? APP_IDLE : DFU_ERROR;
|
||||
}
|
||||
break;
|
||||
case DFU_IDLE:
|
||||
case DFU_DNLOAD_SYNC:
|
||||
case DFU_DNBUSY:
|
||||
case DFU_DNLOAD_IDLE:
|
||||
case DFU_MANIFEST_SYNC:
|
||||
case DFU_MANIFEST:
|
||||
case DFU_MANIFEST_WAIT_RESET:
|
||||
case DFU_UPLOAD_IDLE:
|
||||
{
|
||||
_dfu_state_ctx.state = (tud_dfu_mode_firmware_valid_check_cb()) ? APP_IDLE : DFU_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case DFU_ERROR:
|
||||
default:
|
||||
{
|
||||
_dfu_state_ctx.state = APP_IDLE;
|
||||
case DFU_ERROR:
|
||||
default:
|
||||
{
|
||||
_dfu_state_ctx.state = APP_IDLE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user