Replace dfu_mode with dfu

This commit is contained in:
Jeremiah McCarthy 2021-04-22 14:56:52 -04:00
parent 7b45b38fe4
commit 01661b3f28
4 changed files with 62 additions and 62 deletions

View File

@ -73,7 +73,7 @@ typedef enum {
DFU_MANIFEST_WAIT_RESET = 8, DFU_MANIFEST_WAIT_RESET = 8,
DFU_UPLOAD_IDLE = 9, DFU_UPLOAD_IDLE = 9,
DFU_ERROR = 10, DFU_ERROR = 10,
} dfu_mode_state_t; } dfu_state_t;
// DFU Status // DFU Status
typedef enum { typedef enum {
@ -93,7 +93,7 @@ typedef enum {
DFU_STATUS_ERRPOR = 0x0D, DFU_STATUS_ERRPOR = 0x0D,
DFU_STATUS_ERRUNKNOWN = 0x0E, DFU_STATUS_ERRUNKNOWN = 0x0E,
DFU_STATUS_ERRSTALLEDPKT = 0x0F, DFU_STATUS_ERRSTALLEDPKT = 0x0F,
} dfu_mode_device_status_t; } dfu_device_status_t;
#define DFU_FUNC_ATTR_CAN_DOWNLOAD_BITMASK (1 << 0) #define DFU_FUNC_ATTR_CAN_DOWNLOAD_BITMASK (1 << 0)
#define DFU_FUNC_ATTR_CAN_UPLOAD_BITMASK (1 << 1) #define DFU_FUNC_ATTR_CAN_UPLOAD_BITMASK (1 << 1)
@ -134,7 +134,7 @@ static tu_lookup_table_t const _dfu_request_table =
.items = _dfu_request_lookup .items = _dfu_request_lookup
}; };
static tu_lookup_entry_t const _dfu_mode_state_lookup[] = static tu_lookup_entry_t const _dfu_state_lookup[] =
{ {
{ .key = APP_IDLE , .data = "APP_IDLE" }, { .key = APP_IDLE , .data = "APP_IDLE" },
{ .key = APP_DETACH , .data = "APP_DETACH" }, { .key = APP_DETACH , .data = "APP_DETACH" },
@ -149,13 +149,13 @@ static tu_lookup_entry_t const _dfu_mode_state_lookup[] =
{ .key = DFU_ERROR , .data = "DFU_ERROR" }, { .key = DFU_ERROR , .data = "DFU_ERROR" },
}; };
static tu_lookup_table_t const _dfu_mode_state_table = static tu_lookup_table_t const _dfu_state_table =
{ {
.count = TU_ARRAY_SIZE(_dfu_mode_state_lookup), .count = TU_ARRAY_SIZE(_dfu_state_lookup),
.items = _dfu_mode_state_lookup .items = _dfu_state_lookup
}; };
static tu_lookup_entry_t const _dfu_mode_status_lookup[] = static tu_lookup_entry_t const _dfu_status_lookup[] =
{ {
{ .key = DFU_STATUS_OK , .data = "OK" }, { .key = DFU_STATUS_OK , .data = "OK" },
{ .key = DFU_STATUS_ERRTARGET , .data = "errTARGET" }, { .key = DFU_STATUS_ERRTARGET , .data = "errTARGET" },
@ -175,10 +175,10 @@ static tu_lookup_entry_t const _dfu_mode_status_lookup[] =
{ .key = DFU_STATUS_ERRSTALLEDPKT , .data = "errSTALLEDPKT" }, { .key = DFU_STATUS_ERRSTALLEDPKT , .data = "errSTALLEDPKT" },
}; };
static tu_lookup_table_t const _dfu_mode_status_table = static tu_lookup_table_t const _dfu_status_table =
{ {
.count = TU_ARRAY_SIZE(_dfu_mode_status_lookup), .count = TU_ARRAY_SIZE(_dfu_status_lookup),
.items = _dfu_mode_status_lookup .items = _dfu_status_lookup
}; };
#endif #endif
@ -186,8 +186,8 @@ static tu_lookup_table_t const _dfu_mode_status_table =
#define dfu_debug_print_context() \ #define dfu_debug_print_context() \
{ \ { \
TU_LOG2(" DFU at State: %s\r\n Status: %s\r\n", \ TU_LOG2(" DFU at State: %s\r\n Status: %s\r\n", \
tu_lookup_find(&_dfu_mode_state_table, _dfu_state_ctx.state), \ tu_lookup_find(&_dfu_state_table, _dfu_state_ctx.state), \
tu_lookup_find(&_dfu_mode_status_table, _dfu_state_ctx.status) ); \ tu_lookup_find(&_dfu_status_table, _dfu_state_ctx.status) ); \
} }

View File

@ -28,7 +28,7 @@
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU_MODE) #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU_MODE)
#include "dfu_mode_device.h" #include "dfu_device.h"
#include "device/usbd_pvt.h" #include "device/usbd_pvt.h"
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@ -40,8 +40,8 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
typedef struct TU_ATTR_PACKED typedef struct TU_ATTR_PACKED
{ {
dfu_mode_device_status_t status; dfu_device_status_t status;
dfu_mode_state_t state; dfu_state_t state;
uint8_t attrs; uint8_t attrs;
bool blk_transfer_in_proc; bool blk_transfer_in_proc;
@ -49,17 +49,17 @@ typedef struct TU_ATTR_PACKED
uint16_t last_block_num; uint16_t last_block_num;
uint16_t last_transfer_len; uint16_t last_transfer_len;
CFG_TUSB_MEM_ALIGN uint8_t transfer_buf[CFG_TUD_DFU_TRANSFER_BUFFER_SIZE]; CFG_TUSB_MEM_ALIGN uint8_t transfer_buf[CFG_TUD_DFU_TRANSFER_BUFFER_SIZE];
} dfu_mode_state_ctx_t; } dfu_state_ctx_t;
// Only a single dfu state is allowed // Only a single dfu state is allowed
CFG_TUSB_MEM_SECTION static dfu_mode_state_ctx_t _dfu_state_ctx; CFG_TUSB_MEM_SECTION static dfu_state_ctx_t _dfu_state_ctx;
static void dfu_req_dnload_setup(uint8_t rhport, tusb_control_request_t const * request); static void dfu_req_dnload_setup(uint8_t rhport, tusb_control_request_t const * request);
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);
static uint16_t dfu_req_upload(uint8_t rhport, tusb_control_request_t const * request, uint16_t block_num, uint16_t wLength); static uint16_t dfu_req_upload(uint8_t rhport, tusb_control_request_t const * request, uint16_t block_num, uint16_t wLength);
static void dfu_mode_req_dnload_reply(uint8_t rhport, tusb_control_request_t const * request); static void dfu_req_dnload_reply(uint8_t rhport, tusb_control_request_t const * request);
static bool dfu_mode_state_machine(uint8_t rhport, tusb_control_request_t const * request); static bool dfu_state_machine(uint8_t rhport, tusb_control_request_t const * request);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@ -83,9 +83,9 @@ void dfu_moded_reset(uint8_t rhport)
{ {
_dfu_state_ctx.state = DFU_IDLE; _dfu_state_ctx.state = DFU_IDLE;
} else { } else {
if ( tud_dfu_mode_usb_reset_cb ) if ( tud_dfu_usb_reset_cb )
{ {
tud_dfu_mode_usb_reset_cb(rhport, &_dfu_state_ctx.state); tud_dfu_usb_reset_cb(rhport, &_dfu_state_ctx.state);
} else { } else {
switch (_dfu_state_ctx.state) switch (_dfu_state_ctx.state)
{ {
@ -98,7 +98,7 @@ void dfu_moded_reset(uint8_t rhport)
case DFU_MANIFEST_WAIT_RESET: case DFU_MANIFEST_WAIT_RESET:
case DFU_UPLOAD_IDLE: case DFU_UPLOAD_IDLE:
{ {
_dfu_state_ctx.state = (tud_dfu_mode_firmware_valid_check_cb()) ? APP_IDLE : DFU_ERROR; _dfu_state_ctx.state = (tud_dfu_firmware_valid_check_cb()) ? APP_IDLE : DFU_ERROR;
} }
break; break;
@ -114,7 +114,7 @@ void dfu_moded_reset(uint8_t rhport)
if(_dfu_state_ctx.state == APP_IDLE) if(_dfu_state_ctx.state == APP_IDLE)
{ {
tud_dfu_mode_reboot_to_rt_cb(); tud_dfu_reboot_to_rt_cb();
} }
_dfu_state_ctx.status = DFU_STATUS_OK; _dfu_state_ctx.status = DFU_STATUS_OK;
@ -155,7 +155,7 @@ bool dfu_moded_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_reque
{ {
if ( (stage == CONTROL_STAGE_DATA) && (request->bRequest == DFU_DNLOAD_SYNC) ) if ( (stage == CONTROL_STAGE_DATA) && (request->bRequest == DFU_DNLOAD_SYNC) )
{ {
dfu_mode_req_dnload_reply(rhport, request); dfu_req_dnload_reply(rhport, request);
return true; return true;
} }
@ -185,14 +185,14 @@ bool dfu_moded_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_reque
case DFU_REQUEST_GETSTATE: case DFU_REQUEST_GETSTATE:
case DFU_REQUEST_ABORT: case DFU_REQUEST_ABORT:
{ {
return dfu_mode_state_machine(rhport, request); return dfu_state_machine(rhport, request);
} }
break; break;
default: default:
{ {
TU_LOG2(" DFU Nonstandard Request: %u\r\n", request->bRequest); TU_LOG2(" DFU Nonstandard Request: %u\r\n", request->bRequest);
return ( tud_dfu_mode_req_nonstandard_cb ) ? tud_dfu_mode_req_nonstandard_cb(rhport, stage, request) : false; return ( tud_dfu_req_nonstandard_cb ) ? tud_dfu_req_nonstandard_cb(rhport, stage, request) : false;
} }
break; break;
} }
@ -203,7 +203,7 @@ bool dfu_moded_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_reque
static uint16_t dfu_req_upload(uint8_t rhport, tusb_control_request_t const * request, uint16_t block_num, uint16_t wLength) static uint16_t dfu_req_upload(uint8_t rhport, tusb_control_request_t const * request, uint16_t block_num, uint16_t wLength)
{ {
TU_VERIFY( wLength <= CFG_TUD_DFU_TRANSFER_BUFFER_SIZE); TU_VERIFY( wLength <= CFG_TUD_DFU_TRANSFER_BUFFER_SIZE);
uint16_t retval = tud_dfu_mode_req_upload_data_cb(block_num, (uint8_t *)&_dfu_state_ctx.transfer_buf, wLength); uint16_t retval = tud_dfu_req_upload_data_cb(block_num, (uint8_t *)&_dfu_state_ctx.transfer_buf, wLength);
tud_control_xfer(rhport, request, &_dfu_state_ctx.transfer_buf, retval); tud_control_xfer(rhport, request, &_dfu_state_ctx.transfer_buf, retval);
return retval; return retval;
} }
@ -213,14 +213,14 @@ static void dfu_req_getstatus_reply(uint8_t rhport, tusb_control_request_t const
dfu_status_req_payload_t resp; dfu_status_req_payload_t resp;
resp.bStatus = _dfu_state_ctx.status; resp.bStatus = _dfu_state_ctx.status;
if ( tud_dfu_mode_get_poll_timeout_cb ) if ( tud_dfu_get_poll_timeout_cb )
{ {
tud_dfu_mode_get_poll_timeout_cb((uint8_t *)&resp.bwPollTimeout); tud_dfu_get_poll_timeout_cb((uint8_t *)&resp.bwPollTimeout);
} else { } else {
memset((uint8_t *)&resp.bwPollTimeout, 0x00, 3); memset((uint8_t *)&resp.bwPollTimeout, 0x00, 3);
} }
resp.bState = _dfu_state_ctx.state; resp.bState = _dfu_state_ctx.state;
resp.iString = ( tud_dfu_mode_get_status_desc_table_index_cb ) ? tud_dfu_mode_get_status_desc_table_index_cb() : 0; resp.iString = ( tud_dfu_get_status_desc_table_index_cb ) ? tud_dfu_get_status_desc_table_index_cb() : 0;
tud_control_xfer(rhport, request, &resp, sizeof(dfu_status_req_payload_t)); tud_control_xfer(rhport, request, &resp, sizeof(dfu_status_req_payload_t));
} }
@ -242,26 +242,26 @@ static void dfu_req_dnload_setup(uint8_t rhport, tusb_control_request_t const *
tud_control_xfer(rhport, request, &_dfu_state_ctx.transfer_buf, request->wLength); tud_control_xfer(rhport, request, &_dfu_state_ctx.transfer_buf, request->wLength);
} }
static void dfu_mode_req_dnload_reply(uint8_t rhport, tusb_control_request_t const * request) static void dfu_req_dnload_reply(uint8_t rhport, tusb_control_request_t const * request)
{ {
uint8_t bwPollTimeout[3] = {0,0,0}; uint8_t bwPollTimeout[3] = {0,0,0};
if ( tud_dfu_mode_get_poll_timeout_cb ) if ( tud_dfu_get_poll_timeout_cb )
{ {
tud_dfu_mode_get_poll_timeout_cb((uint8_t *)&bwPollTimeout); tud_dfu_get_poll_timeout_cb((uint8_t *)&bwPollTimeout);
} }
tud_dfu_mode_start_poll_timeout_cb((uint8_t *)&bwPollTimeout); tud_dfu_start_poll_timeout_cb((uint8_t *)&bwPollTimeout);
// TODO: I want the real xferred len, not what is expected. May need to change usbd.c to do this. // TODO: I want the real xferred len, not what is expected. May need to change usbd.c to do this.
tud_dfu_mode_req_dnload_data_cb(_dfu_state_ctx.last_block_num, (uint8_t *)&_dfu_state_ctx.transfer_buf, _dfu_state_ctx.last_transfer_len); tud_dfu_req_dnload_data_cb(_dfu_state_ctx.last_block_num, (uint8_t *)&_dfu_state_ctx.transfer_buf, _dfu_state_ctx.last_transfer_len);
_dfu_state_ctx.blk_transfer_in_proc = false; _dfu_state_ctx.blk_transfer_in_proc = false;
_dfu_state_ctx.last_block_num = 0; _dfu_state_ctx.last_block_num = 0;
_dfu_state_ctx.last_transfer_len = 0; _dfu_state_ctx.last_transfer_len = 0;
} }
void tud_dfu_mode_poll_timeout_done() void tud_dfu_poll_timeout_done()
{ {
if (_dfu_state_ctx.state == DFU_DNBUSY) if (_dfu_state_ctx.state == DFU_DNBUSY)
{ {
@ -273,10 +273,10 @@ void tud_dfu_mode_poll_timeout_done()
} }
} }
static bool dfu_mode_state_machine(uint8_t rhport, tusb_control_request_t const * request) static bool dfu_state_machine(uint8_t rhport, tusb_control_request_t const * request)
{ {
TU_LOG2(" DFU Request: %s\r\n", tu_lookup_find(&_dfu_request_table, request->bRequest)); TU_LOG2(" DFU Request: %s\r\n", tu_lookup_find(&_dfu_request_table, request->bRequest));
TU_LOG2(" DFU State Machine: %s\r\n", tu_lookup_find(&_dfu_mode_state_table, _dfu_state_ctx.state)); TU_LOG2(" DFU State Machine: %s\r\n", tu_lookup_find(&_dfu_state_table, _dfu_state_ctx.state));
switch (_dfu_state_ctx.state) switch (_dfu_state_ctx.state)
{ {
@ -398,7 +398,7 @@ static bool dfu_mode_state_machine(uint8_t rhport, tusb_control_request_t const
_dfu_state_ctx.blk_transfer_in_proc = true; _dfu_state_ctx.blk_transfer_in_proc = true;
dfu_req_dnload_setup(rhport, request); dfu_req_dnload_setup(rhport, request);
} else { } else {
if ( tud_dfu_mode_device_data_done_check_cb() ) if ( tud_dfu_device_data_done_check_cb() )
{ {
_dfu_state_ctx.state = DFU_MANIFEST_SYNC; _dfu_state_ctx.state = DFU_MANIFEST_SYNC;
tud_control_status(rhport, request); tud_control_status(rhport, request);
@ -424,9 +424,9 @@ static bool dfu_mode_state_machine(uint8_t rhport, tusb_control_request_t const
case DFU_REQUEST_ABORT: case DFU_REQUEST_ABORT:
{ {
if ( tud_dfu_mode_abort_cb ) if ( tud_dfu_abort_cb )
{ {
tud_dfu_mode_abort_cb(); tud_dfu_abort_cb();
} }
_dfu_state_ctx.state = DFU_IDLE; _dfu_state_ctx.state = DFU_IDLE;
} }
@ -453,7 +453,7 @@ static bool dfu_mode_state_machine(uint8_t rhport, tusb_control_request_t const
_dfu_state_ctx.state = DFU_MANIFEST; _dfu_state_ctx.state = DFU_MANIFEST;
dfu_req_getstatus_reply(rhport, request); dfu_req_getstatus_reply(rhport, request);
} else { } else {
if ( tud_dfu_mode_firmware_valid_check_cb() ) if ( tud_dfu_firmware_valid_check_cb() )
{ {
_dfu_state_ctx.state = DFU_IDLE; _dfu_state_ctx.state = DFU_IDLE;
} }
@ -533,9 +533,9 @@ static bool dfu_mode_state_machine(uint8_t rhport, tusb_control_request_t const
case DFU_REQUEST_ABORT: case DFU_REQUEST_ABORT:
{ {
if (tud_dfu_mode_abort_cb) if (tud_dfu_abort_cb)
{ {
tud_dfu_mode_abort_cb(); tud_dfu_abort_cb();
} }
_dfu_state_ctx.state = DFU_IDLE; _dfu_state_ctx.state = DFU_IDLE;
} }

View File

@ -24,8 +24,8 @@
* This file is part of the TinyUSB stack. * This file is part of the TinyUSB stack.
*/ */
#ifndef _TUSB_DFU_MODE_DEVICE_H_ #ifndef _TUSB_DFU_DEVICE_H_
#define _TUSB_DFU_MODE_DEVICE_H_ #define _TUSB_DFU_DEVICE_H_
#include "common/tusb_common.h" #include "common/tusb_common.h"
#include "device/usbd.h" #include "device/usbd.h"
@ -40,10 +40,10 @@
// Application Callback API (weak is optional) // Application Callback API (weak is optional)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Invoked when a reset is received to check if firmware is valid // Invoked when a reset is received to check if firmware is valid
bool tud_dfu_mode_firmware_valid_check_cb(void); bool tud_dfu_firmware_valid_check_cb(void);
// Invoked when the device must reboot to dfu runtime mode // Invoked when the device must reboot to dfu runtime mode
void tud_dfu_mode_reboot_to_rt_cb(void); void tud_dfu_reboot_to_rt_cb(void);
// Invoked during initialization of the dfu driver to set attributes // Invoked during initialization of the dfu driver to set attributes
// Return byte set with bitmasks: // Return byte set with bitmasks:
@ -52,19 +52,19 @@ void tud_dfu_mode_reboot_to_rt_cb(void);
// DFU_FUNC_ATTR_MANIFESTATION_TOLERANT_BITMASK // DFU_FUNC_ATTR_MANIFESTATION_TOLERANT_BITMASK
// DFU_FUNC_ATTR_WILL_DETACH_BITMASK // DFU_FUNC_ATTR_WILL_DETACH_BITMASK
// Note: This should match the USB descriptor // Note: This should match the USB descriptor
uint8_t tud_dfu_mode_init_attrs_cb(void); uint8_t tud_dfu_init_attrs_cb(void);
// Invoked during a DFU_GETSTATUS request to get for the string index // Invoked during a DFU_GETSTATUS request to get for the string index
// to the status description string table. // to the status description string table.
TU_ATTR_WEAK uint8_t tud_dfu_mode_get_status_desc_table_index_cb(void); TU_ATTR_WEAK uint8_t tud_dfu_get_status_desc_table_index_cb(void);
// Invoked during a USB reset // Invoked during a USB reset
// Lets the app perform custom behavior on a USB reset. // Lets the app perform custom behavior on a USB reset.
// If not defined, the default behavior remains the DFU specification of // If not defined, the default behavior remains the DFU specification of
// Checking the firmware valid and changing to the error state or rebooting to runtime // Checking the firmware valid and changing to the error state or rebooting to runtime
// Note: If used, the application must perform the reset logic for all states. // Note: If used, the application must perform the reset logic for all states.
// Changing the state to APP_IDLE will result in tud_dfu_mode_reboot_to_rt_cb being called // Changing the state to APP_IDLE will result in tud_dfu_reboot_to_rt_cb being called
TU_ATTR_WEAK void tud_dfu_mode_usb_reset_cb(uint8_t rhport, dfu_mode_state_t *state); TU_ATTR_WEAK void tud_dfu_usb_reset_cb(uint8_t rhport, dfu_state_t *state);
// Invoked during a DFU_GETSTATUS request to set the timeout in ms to use // Invoked during a DFU_GETSTATUS request to set the timeout in ms to use
// before the subsequent DFU_GETSTATUS requests. // before the subsequent DFU_GETSTATUS requests.
@ -73,7 +73,7 @@ TU_ATTR_WEAK void tud_dfu_mode_usb_reset_cb(uint8_t rhport, dfu_mode_state_t *st
// to allow the device to have time to erase, write memory, etc. // to allow the device to have time to erase, write memory, etc.
// ms_timeout is a pointer to array of length 3. // ms_timeout is a pointer to array of length 3.
// Refer to the USB DFU class specification for more details // Refer to the USB DFU class specification for more details
TU_ATTR_WEAK void tud_dfu_mode_get_poll_timeout_cb(uint8_t *ms_timeout); TU_ATTR_WEAK void tud_dfu_get_poll_timeout_cb(uint8_t *ms_timeout);
// Invoked when a DFU_DNLOAD request is received // Invoked when a DFU_DNLOAD request is received
// This should start a timer for ms_timeout ms // This should start a timer for ms_timeout ms
@ -81,40 +81,40 @@ TU_ATTR_WEAK void tud_dfu_mode_get_poll_timeout_cb(uint8_t *ms_timeout);
// NOTE: This callback should return immediately, and not implement the delay // NOTE: This callback should return immediately, and not implement the delay
// internally, as this will hold up the class stack from receiving any packets // internally, as this will hold up the class stack from receiving any packets
// during the DFU_DNLOAD_SYNC and DFU_DNBUSY states // during the DFU_DNLOAD_SYNC and DFU_DNBUSY states
void tud_dfu_mode_start_poll_timeout_cb(uint8_t *ms_timeout); void tud_dfu_start_poll_timeout_cb(uint8_t *ms_timeout);
// Must be called when the poll_timeout has elapsed // Must be called when the poll_timeout has elapsed
void tud_dfu_mode_poll_timeout_done(void); void tud_dfu_poll_timeout_done(void);
// Invoked when a DFU_DNLOAD request is received // Invoked when a DFU_DNLOAD request is received
// This callback takes the wBlockNum chunk of length length and provides it // This callback takes the wBlockNum chunk of length length and provides it
// to the application at the data pointer. This data is only valid for this // to the application at the data pointer. This data is only valid for this
// call, so the app must use it not or copy it. // call, so the app must use it not or copy it.
void tud_dfu_mode_req_dnload_data_cb(uint16_t wBlockNum, uint8_t* data, uint16_t length); void tud_dfu_req_dnload_data_cb(uint16_t wBlockNum, uint8_t* data, uint16_t length);
// Invoked during the last DFU_DNLOAD request, signifying that the host believes // Invoked during the last DFU_DNLOAD request, signifying that the host believes
// it is done transmitting data. // it is done transmitting data.
// Return true if the application agrees there is no more data // Return true if the application agrees there is no more data
// Return false if the device disagrees, which will stall the pipe, and the Host // Return false if the device disagrees, which will stall the pipe, and the Host
// should initiate a recovery procedure // should initiate a recovery procedure
bool tud_dfu_mode_device_data_done_check_cb(void); bool tud_dfu_device_data_done_check_cb(void);
// Invoked when the Host has terminated a download or upload transfer // Invoked when the Host has terminated a download or upload transfer
TU_ATTR_WEAK void tud_dfu_mode_abort_cb(void); TU_ATTR_WEAK void tud_dfu_abort_cb(void);
// Invoked when a DFU_UPLOAD request is received // Invoked when a DFU_UPLOAD request is received
// This callback must populate data with up to length bytes // This callback must populate data with up to length bytes
// Return the number of bytes to write // Return the number of bytes to write
uint16_t tud_dfu_mode_req_upload_data_cb(uint16_t block_num, uint8_t* data, uint16_t length); uint16_t tud_dfu_req_upload_data_cb(uint16_t block_num, uint8_t* data, uint16_t length);
// Invoked when a nonstandard request is received // Invoked when a nonstandard request is received
// Use may be vendor specific. // Use may be vendor specific.
// Return false to stall // Return false to stall
TU_ATTR_WEAK bool tud_dfu_mode_req_nonstandard_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request); TU_ATTR_WEAK bool tud_dfu_req_nonstandard_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
// Invoked during a DFU_GETSTATUS request to get for the string index // Invoked during a DFU_GETSTATUS request to get for the string index
// to the status description string table. // to the status description string table.
TU_ATTR_WEAK uint8_t tud_dfu_mode_get_status_desc_table_index_cb(void); TU_ATTR_WEAK uint8_t tud_dfu_get_status_desc_table_index_cb(void);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Internal Class Driver API // Internal Class Driver API
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+

View File

@ -97,7 +97,7 @@
#endif #endif
#if CFG_TUD_DFU_MODE #if CFG_TUD_DFU_MODE
#include "class/dfu/dfu_mode_device.h" #include "class/dfu/dfu_device.h"
#endif #endif
#if CFG_TUD_NET #if CFG_TUD_NET