summaryrefslogtreecommitdiff
path: root/src/class/dfu/dfu_device.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/class/dfu/dfu_device.h')
-rw-r--r--src/class/dfu/dfu_device.h62
1 files changed, 30 insertions, 32 deletions
diff --git a/src/class/dfu/dfu_device.h b/src/class/dfu/dfu_device.h
index d5d464f3b..2d398aada 100644
--- a/src/class/dfu/dfu_device.h
+++ b/src/class/dfu/dfu_device.h
@@ -37,53 +37,51 @@
// Class Driver Default Configure & Validation
//--------------------------------------------------------------------+
-#if !defined(CFG_TUD_DFU_TRANSFER_BUFFER_SIZE)
- #error "CFG_TUD_DFU_TRANSFER_BUFFER_SIZE must be defined, it has to be set to the buffer size used in TUD_DFU_DESCRIPTOR"
+#if !defined(CFG_TUD_DFU_TRANSFER_BUFSIZE)
+ #error "CFG_TUD_DFU_TRANSFER_BUFSIZE must be defined, it has to be set to the buffer size used in TUD_DFU_DESCRIPTOR"
#endif
//--------------------------------------------------------------------+
-// Application Callback API (weak is optional)
+// Application API
//--------------------------------------------------------------------+
-// Invoked during DFU_MANIFEST_SYNC get status request to check if firmware is valid
-// 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
-// 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 uint32_t tud_dfu_get_status_cb(uint8_t alt, uint8_t state);
+// Must be called when the application is done with flashing started by
+// tud_dfu_download_cb() and tud_dfu_manifest_cb().
+// status is DFU_STATUS_OK if successful, any other error status will cause state to enter dfuError
+void tud_dfu_finish_flashing(uint8_t status);
-// 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.
-// 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
-// call, so the app must use it not or copy it.
-void tud_dfu_download_cb(uint8_t alt, uint16_t wBlockNum, uint8_t* data, uint16_t length);
+//--------------------------------------------------------------------+
+// Application Callback API (weak is optional)
+//--------------------------------------------------------------------+
-// Must be called when the application is done using the last block of data
-// provided by tud_dfu_download_cb
-void tud_dfu_download_complete(void);
+// Note: alt is used as the partition number, in order to support multiple partitions like FLASH, EEPROM, etc.
-// Invoked during the last DFU_DNLOAD request, signifying that the host believes
-// it is done transmitting data.
-// alt is used as the partition number, in order to support multiple partitions like FLASH, EEPROM, etc.
-// 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
-// should initiate a recovery procedure
-bool tud_dfu_device_data_done_check_cb(uint8_t alt);
+// Invoked right before tud_dfu_download_cb() (state=DFU_DNBUSY) or tud_dfu_manifest_cb() (state=DFU_MANIFEST)
+// Application return timeout in milliseconds (bwPollTimeout) for the next download/manifest operation.
+// During this period, USB host won't try to communicate with us.
+uint32_t tud_dfu_get_timeout_cb(uint8_t alt, uint8_t state);
-// Invoked when the Host has terminated a download or upload transfer
-TU_ATTR_WEAK void tud_dfu_abort_cb(uint8_t alt);
+// Invoked when received DFU_DNLOAD (wLength>0) following by DFU_GETSTATUS (state=DFU_DNBUSY) requests
+// This callback could be returned before flashing op is complete (async).
+// Once finished flashing, application must call tud_dfu_finish_flashing()
+void tud_dfu_download_cb (uint8_t alt, uint16_t block_num, uint8_t const *data, uint16_t length);
+
+// Invoked when download process is complete, received DFU_DNLOAD (wLength=0) following by DFU_GETSTATUS (state=Manifest)
+// Application can do checksum, or actual flashing if buffered entire image previously.
+// Once finished flashing, application must call tud_dfu_finish_flashing()
+void tud_dfu_manifest_cb(uint8_t alt);
-// Invoked when a DFU_UPLOAD request is received
-// alt is used as the partition number, in order to support multiple partitions like FLASH, EEPROM, etc.
-// This callback must populate data with up to length bytes
-// Return the number of bytes to write
+// Invoked when received DFU_UPLOAD request
+// Application must populate data with up to length bytes and
+// Return the number of written bytes
TU_ATTR_WEAK uint16_t tud_dfu_upload_cb(uint8_t alt, uint16_t block_num, uint8_t* data, uint16_t length);
// Invoked when a DFU_DETACH request is received
TU_ATTR_WEAK void tud_dfu_detach_cb(void);
+// Invoked when the Host has terminated a download or upload transfer
+TU_ATTR_WEAK void tud_dfu_abort_cb(uint8_t alt);
+
//--------------------------------------------------------------------+
// Internal Class Driver API
//--------------------------------------------------------------------+