mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
rename tud_dfu_set_timeout_cb() to tud_dfu_get_status_cb()
also add state as argument
This commit is contained in:
parent
8c48a4a288
commit
86d511f244
@ -125,10 +125,13 @@ bool tud_dfu_firmware_valid_check_cb(uint8_t alt)
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t tud_dfu_set_timeout_cb(uint8_t alt)
|
||||
uint32_t tud_dfu_get_status_cb(uint8_t alt, uint8_t state)
|
||||
{
|
||||
// For example Alt1 (EEPROM) is slow, add 2000ms timeout
|
||||
if ( state == DFU_DNBUSY )
|
||||
{
|
||||
if (alt == 1) return 2000;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -293,18 +293,17 @@ static uint16_t dfu_req_upload(uint8_t rhport, tusb_control_request_t const * re
|
||||
|
||||
static void dfu_req_getstatus_reply(uint8_t rhport, tusb_control_request_t const * request)
|
||||
{
|
||||
dfu_status_req_payload_t resp;
|
||||
|
||||
uint16_t timeout = 0;
|
||||
resp.bStatus = _dfu_state_ctx.status;
|
||||
if(_dfu_state_ctx.state == DFU_DNBUSY && tud_dfu_set_timeout_cb)
|
||||
uint32_t timeout = 0;
|
||||
if ( tud_dfu_get_status_cb )
|
||||
{
|
||||
timeout = tud_dfu_set_timeout_cb(_dfu_state_ctx.alt);
|
||||
|
||||
timeout = tud_dfu_get_status_cb(_dfu_state_ctx.alt, _dfu_state_ctx.state);
|
||||
}
|
||||
resp.bwPollTimeout[0] = TU_U16_LOW(timeout);
|
||||
resp.bwPollTimeout[1] = TU_U16_HIGH(timeout);
|
||||
resp.bwPollTimeout[2] = 0;
|
||||
|
||||
dfu_status_req_payload_t resp;
|
||||
resp.bStatus = _dfu_state_ctx.status;
|
||||
resp.bwPollTimeout[0] = TU_U32_BYTE0(timeout);
|
||||
resp.bwPollTimeout[1] = TU_U32_BYTE1(timeout);
|
||||
resp.bwPollTimeout[2] = TU_U32_BYTE2(timeout);
|
||||
resp.bState = _dfu_state_ctx.state;
|
||||
resp.iString = 0;
|
||||
|
||||
|
@ -48,10 +48,10 @@
|
||||
// alt is used as the partition number, in order to support multiple partitions like FLASH, EEPROM, etc.
|
||||
bool tud_dfu_firmware_valid_check_cb(uint8_t alt);
|
||||
|
||||
// Invoked when a DFU_GETSTATUS request is received in DFU_DNBUSY state
|
||||
// Used to set the bwPollTimeout value, useful for slow Flash in order to make host wait longer
|
||||
// Invoked when a DFU_GETSTATUS request is received
|
||||
// Return the bwPollTimeout value for host's response, useful for slow Flash in order to make host wait longer
|
||||
// alt is used as the partition number, in order to support multiple partitions like FLASH, EEPROM, etc.
|
||||
TU_ATTR_WEAK uint16_t tud_dfu_set_timeout_cb(uint8_t alt);
|
||||
TU_ATTR_WEAK uint32_t tud_dfu_get_status_cb(uint8_t alt, uint8_t state);
|
||||
|
||||
// Invoked when a DFU_DNLOAD request is received
|
||||
// alt is used as the partition number, in order to support multiple partitions like FLASH, EEPROM, etc.
|
||||
|
Loading…
x
Reference in New Issue
Block a user