mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-22 10:20:55 +00: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;
|
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
|
// For example Alt1 (EEPROM) is slow, add 2000ms timeout
|
||||||
if (alt == 1) return 2000;
|
if ( state == DFU_DNBUSY )
|
||||||
|
{
|
||||||
|
if (alt == 1) return 2000;
|
||||||
|
}
|
||||||
return 0;
|
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)
|
static void dfu_req_getstatus_reply(uint8_t rhport, tusb_control_request_t const * request)
|
||||||
{
|
{
|
||||||
dfu_status_req_payload_t resp;
|
uint32_t timeout = 0;
|
||||||
|
if ( tud_dfu_get_status_cb )
|
||||||
uint16_t timeout = 0;
|
|
||||||
resp.bStatus = _dfu_state_ctx.status;
|
|
||||||
if(_dfu_state_ctx.state == DFU_DNBUSY && tud_dfu_set_timeout_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);
|
dfu_status_req_payload_t resp;
|
||||||
resp.bwPollTimeout[2] = 0;
|
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.bState = _dfu_state_ctx.state;
|
||||||
resp.iString = 0;
|
resp.iString = 0;
|
||||||
|
|
||||||
|
@ -48,10 +48,10 @@
|
|||||||
// alt is used as the partition number, in order to support multiple partitions like FLASH, EEPROM, etc.
|
// 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);
|
bool tud_dfu_firmware_valid_check_cb(uint8_t alt);
|
||||||
|
|
||||||
// Invoked when a DFU_GETSTATUS request is received in DFU_DNBUSY state
|
// Invoked when a DFU_GETSTATUS request is received
|
||||||
// Used to set the bwPollTimeout value, useful for slow Flash in order to make host wait longer
|
// 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.
|
// 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
|
// 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.
|
// 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