dfu: force USB reset when download end in DFUIdle state

This commit is contained in:
Gwenhael Goavec-Merou 2021-12-23 07:22:06 +01:00
parent 9d494c1be1
commit 0979194da2
1 changed files with 5 additions and 0 deletions

View File

@ -442,11 +442,13 @@ int DFU::set_state(char newState)
* an handle others states */
if (newState == STATE_appIDLE) {
// reset
ret = libusb_reset_device(dev_handle);
// reenum
} else { // download or upload
// are handled by download() and upload()
return -2;
}
return ret;
break;
case STATE_dfuDNLOAD_IDLE:
if (newState == STATE_dfuMANIFEST_SYNC) {
@ -770,6 +772,9 @@ int DFU::download()
}
} while (must_continue);
if (status.bState == STATE_dfuIDLE)
set_state(STATE_appIDLE);
return ret_val;
}