summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2021-07-07 19:01:00 +0200
committerHiFiPhile <[email protected]>2021-07-07 19:01:00 +0200
commit7e883e0f41a4fdda699bbaf1d64a28d82527b8f9 (patch)
tree529df69dc7257e9f1908380206fccd6eab726396 /examples
parent71c00432610780f07d0e0776eacdda1186481854 (diff)
Refactor with one DFU functionnal descriptor
Diffstat (limited to 'examples')
-rw-r--r--examples/device/dfu/src/tusb_config.h8
-rw-r--r--examples/device/dfu/src/usb_descriptors.c7
2 files changed, 8 insertions, 7 deletions
diff --git a/examples/device/dfu/src/tusb_config.h b/examples/device/dfu/src/tusb_config.h
index 0df46c14e..55aa19922 100644
--- a/examples/device/dfu/src/tusb_config.h
+++ b/examples/device/dfu/src/tusb_config.h
@@ -76,14 +76,16 @@
#define CFG_TUD_ENDPOINT0_SIZE 64
#endif
-// DFU buffer size, must to be set to the largest buffer size used by an any given storage type
-#define CFG_TUD_DFU_TRANSFER_BUFFER_SIZE 4096
-
//------------- CLASS -------------//
#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_MODE_DESCRIPTOR
+#define CFG_TUD_DFU_TRANSFER_BUFFER_SIZE 4096
+
#ifdef __cplusplus
}
#endif
diff --git a/examples/device/dfu/src/usb_descriptors.c b/examples/device/dfu/src/usb_descriptors.c
index 9565da9b2..8c5eee455 100644
--- a/examples/device/dfu/src/usb_descriptors.c
+++ b/examples/device/dfu/src/usb_descriptors.c
@@ -87,7 +87,7 @@ enum
ITF_NUM_TOTAL
};
-#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + 2 * TUD_DFU_MODE_DESC_LEN)
+#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_DFU_MODE_DESC_LEN)
#define FUNC_ATTRS (DFU_FUNC_ATTR_CAN_UPLOAD_BITMASK | DFU_FUNC_ATTR_CAN_DOWNLOAD_BITMASK)
@@ -96,9 +96,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, string index, attributes, detach timeout, transfer size */
- TUD_DFU_MODE_DESCRIPTOR(ITF_NUM_DFU_MODE, 0, 4, FUNC_ATTRS, 1000, CFG_TUD_DFU_TRANSFER_BUFFER_SIZE),
- TUD_DFU_MODE_DESCRIPTOR(ITF_NUM_DFU_MODE, 1, 5, FUNC_ATTRS, 1000, CFG_TUD_DFU_TRANSFER_BUFFER_SIZE),
+ // Interface number, attributes, detach timeout, transfer size, string index 0, [string index 1 ... string index n]
+ TUD_DFU_MODE_DESCRIPTOR(ITF_NUM_DFU_MODE, FUNC_ATTRS, 1000, CFG_TUD_DFU_TRANSFER_BUFFER_SIZE, 4, 5),
};
// Invoked when received GET CONFIGURATION DESCRIPTOR