aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKévin Redon <kredon@sysmocom.de>2019-01-03 18:13:11 +0100
committerKévin Redon <kredon@sysmocom.de>2019-01-16 18:41:23 +0100
commit9e94e7d7ca087afaad8a58bb6f3cb19f3fd9b438 (patch)
tree8c8c4fe679d469a40cfae3390c82abcd18e0ac26
parent2f8fcbbef6117af05812ff0676587ab45cef3234 (diff)
make USB descriptor available for the two state machines
this is required to know the DFU bmAttributes since they affect the state machine Change-Id: Ib3907423bb9e197f53ed4522e8a5789a3d29489e
-rw-r--r--usb/class/dfu/device/dfudf.c7
-rw-r--r--usb/class/dfu/device/dfudf_desc.h10
-rw-r--r--usb_start.c3
3 files changed, 15 insertions, 5 deletions
diff --git a/usb/class/dfu/device/dfudf.c b/usb/class/dfu/device/dfudf.c
index 15a89fc..42b708b 100644
--- a/usb/class/dfu/device/dfudf.c
+++ b/usb/class/dfu/device/dfudf.c
@@ -22,8 +22,9 @@
#include "dfudf.h"
#include "usb_protocol_dfu.h"
+#include "dfudf_desc.h"
-/** USB Device DFU Fucntion Specific Data */
+/** USB Device DFU Function Specific Data */
struct dfudf_func_data {
/** DFU Interface information */
uint8_t func_iface;
@@ -34,6 +35,10 @@ struct dfudf_func_data {
static struct usbdf_driver _dfudf;
static struct dfudf_func_data _dfudf_funcd;
+/** USB DFU functional descriptor (with DFU attributes) */
+static const uint8_t usb_dfu_func_desc_bytes[] = {DFUD_IFACE_DESCB};
+static const usb_dfu_func_desc_t* usb_dfu_func_desc = (usb_dfu_func_desc_t*)&usb_dfu_func_desc_bytes;
+
enum usb_dfu_state dfu_state = USB_DFU_STATE_DFU_IDLE;
enum usb_dfu_status dfu_status = USB_DFU_STATUS_OK;
diff --git a/usb/class/dfu/device/dfudf_desc.h b/usb/class/dfu/device/dfudf_desc.h
index 5590e16..cd6ba41 100644
--- a/usb/class/dfu/device/dfudf_desc.h
+++ b/usb/class/dfu/device/dfudf_desc.h
@@ -75,6 +75,11 @@
CONF_USB_DFUD_BMATTRI, \
CONF_USB_DFUD_BMAXPOWER)
+#define DFUD_IFACE_DESCB USB_DFU_FUNC_DESC_BYTES(USB_DFU_ATTRIBUTES_CAN_DOWNLOAD | USB_DFU_ATTRIBUTES_WILL_DETACH, \
+ 0, /**< detaching makes only sense in run-time mode */ \
+ 512, /**< transfer size corresponds to page size for optimal flash writing */ \
+ 0x0110 /**< DFU specification version 1.1 used */ )
+
#define DFUD_IFACE_DESCES \
USB_IFACE_DESC_BYTES(CONF_USB_DFUD_BIFCNUM, \
CONF_USB_DFUD_BALTSET, \
@@ -83,10 +88,7 @@
USB_DFU_SUBCLASS, \
USB_DFU_PROTOCOL_DFU, \
CONF_USB_DFUD_IINTERFACE), \
- USB_DFU_FUNC_DESC_BYTES(USB_DFU_ATTRIBUTES_CAN_DOWNLOAD | USB_DFU_ATTRIBUTES_WILL_DETACH, \
- 0, /**< detaching makes only sense in run-time mode */ \
- 1024, /**< transfer size corresponds to page size for optimal flash writing */ \
- 0x0110 /**< DFU specification version 1.1 used */ )
+ DFUD_IFACE_DESCB
#define DFUD_STR_DESCES \
CONF_USB_DFUD_LANGID_DESC \
diff --git a/usb_start.c b/usb_start.c
index 4f9f875..d911db4 100644
--- a/usb_start.c
+++ b/usb_start.c
@@ -39,6 +39,9 @@ static struct usbd_descriptors single_desc[]
#endif
};
+/** USB DFU functional descriptor (with DFU attributes) */
+static const uint8_t usb_dfu_func_desc_bytes[] = {DFUD_IFACE_DESCB};
+static const usb_dfu_func_desc_t* usb_dfu_func_desc = (usb_dfu_func_desc_t*)&usb_dfu_func_desc_bytes;
/** Ctrl endpoint buffer */
static uint8_t ctrl_buffer[64];