summaryrefslogtreecommitdiff
path: root/examples/device/dfu/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-07-12 20:15:59 +0700
committerhathach <[email protected]>2021-07-12 20:15:59 +0700
commit680b000bd1471d731117ccf4f3fe35579d346cb8 (patch)
tree23b190ae7d3d06281c5839311038190cd051e940 /examples/device/dfu/src
parent2916cd45753ca579ee1d0b475b2daf3f715243b6 (diff)
simplify TUD_DFU_DESCRIPTOR with alternate count
remove CFG_TUD_DFU_ALT_COUNT since there is only one DFU functional descriptor
Diffstat (limited to 'examples/device/dfu/src')
-rw-r--r--examples/device/dfu/src/main.c3
-rw-r--r--examples/device/dfu/src/tusb_config.h2
-rw-r--r--examples/device/dfu/src/usb_descriptors.c9
3 files changed, 8 insertions, 6 deletions
diff --git a/examples/device/dfu/src/main.c b/examples/device/dfu/src/main.c
index f7c27174a..ee201c1c5 100644
--- a/examples/device/dfu/src/main.c
+++ b/examples/device/dfu/src/main.c
@@ -154,8 +154,9 @@ bool tud_dfu_device_data_done_check_cb(uint8_t alt)
return true;
}
-void tud_dfu_abort_cb(void)
+void tud_dfu_abort_cb(uint8_t alt)
{
+ (void) alt;
printf(" Host aborted transfer\r\n");
}
diff --git a/examples/device/dfu/src/tusb_config.h b/examples/device/dfu/src/tusb_config.h
index 7e10b4321..77d907ffc 100644
--- a/examples/device/dfu/src/tusb_config.h
+++ b/examples/device/dfu/src/tusb_config.h
@@ -81,8 +81,6 @@
#define CFG_TUD_DFU_RUNTIME 0
#define CFG_TUD_DFU_MODE 1
-// Count of all alt settings, typically it's the partition count (Flash, EEPROM, etc.)
-#define CFG_TUD_DFU_ALT_COUNT 2
// DFU buffer size, it has to be set to the buffer size used in TUD_DFU_DESCRIPTOR
#define CFG_TUD_DFU_TRANSFER_BUFFER_SIZE 4096
diff --git a/examples/device/dfu/src/usb_descriptors.c b/examples/device/dfu/src/usb_descriptors.c
index 870c18a04..78e94194e 100644
--- a/examples/device/dfu/src/usb_descriptors.c
+++ b/examples/device/dfu/src/usb_descriptors.c
@@ -81,13 +81,16 @@ uint8_t const * tud_descriptor_device_cb(void)
// Configuration Descriptor
//--------------------------------------------------------------------+
+// Number of Alternate Interface (each for 1 flash partition)
+#define ALT_COUNT 2
+
enum
{
ITF_NUM_DFU_MODE,
ITF_NUM_TOTAL
};
-#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_DFU_MODE_DESC_LEN)
+#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_DFU_DESC_LEN(ALT_COUNT))
#define FUNC_ATTRS (DFU_FUNC_ATTR_CAN_UPLOAD_BITMASK | DFU_FUNC_ATTR_CAN_DOWNLOAD_BITMASK)
@@ -96,8 +99,8 @@ uint8_t const desc_configuration[] =
// Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
- // Interface number, attributes, detach timeout, transfer size, string index 0, [string index 1 ... string index n]
- TUD_DFU_DESCRIPTOR(ITF_NUM_DFU_MODE, FUNC_ATTRS, 1000, CFG_TUD_DFU_TRANSFER_BUFFER_SIZE, 4, 5),
+ // Interface number, Alternate count, starting string index, attributes, detach timeout, transfer size
+ TUD_DFU_DESCRIPTOR(ITF_NUM_DFU_MODE, ALT_COUNT, 4, FUNC_ATTRS, 1000, CFG_TUD_DFU_TRANSFER_BUFFER_SIZE),
};
// Invoked when received GET CONFIGURATION DESCRIPTOR