<p>Harald Welte <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/12496">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add USB DFU description<br><br>uses the USB CDC ACM example code as template to create a USB DFU<br>description according to USB DFU specification version 1.1<br><br>USB DFU stack is under LGPLv2.1 or later license<br><br>Change-Id: I7bd6cb46b734ffe8a51f2de7083b4f9e76d385e6<br>---<br>M config/usbd_config.h<br>M gcc/Makefile<br>A usb/class/dfu/device/dfudf.c<br>C usb/class/dfu/device/dfudf.h<br>A usb/class/dfu/device/dfudf_desc.h<br>A usb/class/dfu/usb_protocol_dfu.h<br>R usb_dfu_main.c<br>M usb_start.c<br>M usb_start.h<br>9 files changed, 684 insertions(+), 305 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/config/usbd_config.h b/config/usbd_config.h</span><br><span>index e8334ec..e33f4ba 100644</span><br><span>--- a/config/usbd_config.h</span><br><span>+++ b/config/usbd_config.h</span><br><span>@@ -14,33 +14,54 @@</span><br><span> #define CONF_USBD_HS_SP 0</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-// ---- USB Device Stack CDC ACM Options ----</span><br><span style="color: hsl(120, 100%, 40%);">+// ---- USB Device Stack DFU Options ----</span><br><span> </span><br><span> // <e> Enable String Descriptors</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_str_en</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_STR_EN</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_STR_EN 0</span><br><span style="color: hsl(120, 100%, 40%);">+// <ID> USB_DFUD_STR_EN</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_STR_EN</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_STR_EN 0</span><br><span> #endif</span><br><span> // <s> Language IDs</span><br><span> // <i> Language IDs in c format, split by comma (E.g., 0x0409 ...)</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_langid</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_LANGID</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_LANGID "0x0409"</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_langid</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_LANGID</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_LANGID "0x0409"</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_LANGID_DESC</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_LANGID_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_LANGID_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_LANGID_DESC 4, 0x03, 0x09, 0x04,</span><br><span> #endif</span><br><span> // </e></span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-// <h> CDC ACM Device Descriptor</span><br><span style="color: hsl(120, 100%, 40%);">+// <h> DFU Device Descriptor</span><br><span> </span><br><span> // <o> bcdUSB</span><br><span> // <0x0200=> USB 2.0 version</span><br><span> // <0x0210=> USB 2.1 version</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_bcdusb</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_BCDUSB</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_BCDUSB 0x200</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dfud_bcdusb</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BCDUSB</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BCDUSB 0x200</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+// <o> bDeviceClass</span><br><span style="color: hsl(120, 100%, 40%);">+// <0=> unused</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dfud_bdeviceclass</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BDEVICECLASS</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BDEVICECLASS 0</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+// <o> bDeviceSubClass</span><br><span style="color: hsl(120, 100%, 40%);">+// <0=> unused</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dfud_bdevicesubclass</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BDEVICESUBCLASS</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BDEVICESUBCLASS 0</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+// <o> bDeviceProtocol</span><br><span style="color: hsl(120, 100%, 40%);">+// <0=> unused</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dfud_bdeviceprotocol</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BDEVICEPROTOCOL</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BDEVICEPROTOCOL 0</span><br><span> #endif</span><br><span> </span><br><span> // <o> bMaxPackeSize0</span><br><span>@@ -48,133 +69,149 @@</span><br><span> // <0x0010=> 16 bytes</span><br><span> // <0x0020=> 32 bytes</span><br><span> // <0x0040=> 64 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_bmaxpksz0</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_BMAXPKSZ0</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_BMAXPKSZ0 0x40</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_bmaxpksz0</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BMAXPKSZ0</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BMAXPKSZ0 0x40</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-// <o> idVender <0x0000-0xFFFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_idvender</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_IDVENDER</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_IDVENDER 0x3eb</span><br><span style="color: hsl(120, 100%, 40%);">+// <o> idVendor <0x0000-0xFFFF></span><br><span style="color: hsl(120, 100%, 40%);">+// <0x1d50=> OpenMoko</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_octsim_idvendor</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_OCTSIM_IDVENDOR</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_OCTSIM_IDVENDOR 0x1d50</span><br><span> #endif</span><br><span> </span><br><span> // <o> idProduct <0x0000-0xFFFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_idproduct</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_IDPRODUCT</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_IDPRODUCT 0x2404</span><br><span style="color: hsl(120, 100%, 40%);">+// <0x6140=> sysmoOCTSIM</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_idproduct</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_OCTSIM_IDPRODUCT</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_OCTSIM_IDPRODUCT 0x6140</span><br><span> #endif</span><br><span> </span><br><span> // <o> bcdDevice <0x0000-0xFFFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_bcddevice</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_BCDDEVICE</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_BCDDEVICE 0x100</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_bcddevice</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BCDDEVICE</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BCDDEVICE 0x000</span><br><span> #endif</span><br><span> </span><br><span> // <e> Enable string descriptor of iManufact</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_imanufact_en</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_IMANUFACT_EN</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_IMANUFACT_EN 0</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_imanufact_en</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_IMANUFACT_EN</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IMANUFACT_EN 1</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_IMANUFACT</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_IMANUFACT (CONF_USB_CDCD_ACM_IMANUFACT_EN * (CONF_USB_CDCD_ACM_IMANUFACT_EN))</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_IMANUFACT</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IMANUFACT (CONF_USB_DFUD_IMANUFACT_EN * (CONF_USB_DFUD_IMANUFACT_EN))</span><br><span> #endif</span><br><span> </span><br><span> // <s> Unicode string of iManufact</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_imanufact_str</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_IMANUFACT_STR</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_IMANUFACT_STR "Atmel"</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_imanufact_str</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_IMANUFACT_STR</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IMANUFACT_STR "sysmocom"</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_IMANUFACT_STR_DESC</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_IMANUFACT_STR_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_IMANUFACT_STR_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IMANUFACT_STR_DESC 18, 0x03, 's', 0x00, 'y', 0x00, 's', 0x00, 'm', 0x00, 'o', 0x00, 'c', 0x00, 'o', 0x00, 'm', 0x00,</span><br><span> #endif</span><br><span> </span><br><span> // </e></span><br><span> </span><br><span> // <e> Enable string descriptor of iProduct</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_iproduct_en</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_IPRODUCT_EN</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_IPRODUCT_EN 0</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_iproduct_en</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_IPRODUCT_EN</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IPRODUCT_EN 1</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_IPRODUCT</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_IPRODUCT                                                                                     \</span><br><span style="color: hsl(0, 100%, 40%);">-        (CONF_USB_CDCD_ACM_IPRODUCT_EN * (CONF_USB_CDCD_ACM_IMANUFACT_EN + CONF_USB_CDCD_ACM_IPRODUCT_EN))</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_IPRODUCT</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IPRODUCT                                                                                     \</span><br><span style="color: hsl(120, 100%, 40%);">+      (CONF_USB_DFUD_IPRODUCT_EN * (CONF_USB_DFUD_IMANUFACT_EN + CONF_USB_DFUD_IPRODUCT_EN))</span><br><span> #endif</span><br><span> </span><br><span> // <s> Unicode string of iProduct</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_iproduct_str</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_IPRODUCT_STR</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_IPRODUCT_STR "CDC ACM Serial Bridge Demo"</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_iproduct_str</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_IPRODUCT_STR</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IPRODUCT_STR "sysmoOCTSIM"</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_IPRODUCT_STR_DESC</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_IPRODUCT_STR_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_IPRODUCT_STR_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IPRODUCT_STR_DESC 24, 0x03, 's', 0x00, 'y', 0x00, 's', 0x00, 'm', 0x00, 'o', 0x00, 'O', 0x00, 'C', 0x00, 'T', 0x00, 'S', 0x00, 'I', 0x00, 'M', 0x00,</span><br><span> #endif</span><br><span> </span><br><span> // </e></span><br><span> </span><br><span> // <e> Enable string descriptor of iSerialNum</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_iserialnum_en</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_ISERIALNUM_EN</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_ISERIALNUM_EN 0</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_iserialnum_en</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_ISERIALNUM_EN</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_ISERIALNUM_EN 0</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_ISERIALNUM</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_ISERIALNUM                                                                                   \</span><br><span style="color: hsl(0, 100%, 40%);">-   (CONF_USB_CDCD_ACM_ISERIALNUM_EN                                                                                   \</span><br><span style="color: hsl(0, 100%, 40%);">-     * (CONF_USB_CDCD_ACM_IMANUFACT_EN + CONF_USB_CDCD_ACM_IPRODUCT_EN + CONF_USB_CDCD_ACM_ISERIALNUM_EN))</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_ISERIALNUM</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_ISERIALNUM                                                                                   \</span><br><span style="color: hsl(120, 100%, 40%);">+        (CONF_USB_DFUD_ISERIALNUM_EN                                                                                   \</span><br><span style="color: hsl(120, 100%, 40%);">+       * (CONF_USB_DFUD_IMANUFACT_EN + CONF_USB_DFUD_IPRODUCT_EN + CONF_USB_DFUD_ISERIALNUM_EN))</span><br><span> #endif</span><br><span> </span><br><span> // <s> Unicode string of iSerialNum</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_iserialnum_str</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_ISERIALNUM_STR</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_ISERIALNUM_STR "123456789ABCDEF"</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_iserialnum_str</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_ISERIALNUM_STR</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_ISERIALNUM_STR "123456789ABCDEF"</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_ISERIALNUM_STR_DESC</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_ISERIALNUM_STR_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_ISERIALNUM_STR_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_ISERIALNUM_STR_DESC </span><br><span> #endif</span><br><span> </span><br><span> // </e></span><br><span> </span><br><span> // <o> bNumConfigurations <0x01-0xFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_bnumconfig</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_BNUMCONFIG</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_BNUMCONFIG 0x1</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_bnumconfig</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BNUMCONFIG</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BNUMCONFIG 0x1</span><br><span> #endif</span><br><span> </span><br><span> // </h></span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-// <h> CDC ACM Configuration Descriptor</span><br><span style="color: hsl(0, 100%, 40%);">-// <o> bConfigurationValue <0x01-0xFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_bconfigval</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_BCONFIGVAL</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_BCONFIGVAL 0x1</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(0, 100%, 40%);">-// <e> Enable string descriptor of iConfig</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_iconfig_en</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_ICONFIG_EN</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_ICONFIG_EN 0</span><br><span style="color: hsl(120, 100%, 40%);">+// <h> DFU Configuration Descriptor</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+// <o> wTotalLength <0x01-0xFF></span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_wtotallength</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_WTOTALLENGTH</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_WTOTALLENGTH 27</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_ICONFIG</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_ICONFIG                                                                                      \</span><br><span style="color: hsl(0, 100%, 40%);">-   (CONF_USB_CDCD_ACM_ICONFIG_EN                                                                                      \</span><br><span style="color: hsl(0, 100%, 40%);">-     * (CONF_USB_CDCD_ACM_IMANUFACT_EN + CONF_USB_CDCD_ACM_IPRODUCT_EN + CONF_USB_CDCD_ACM_ISERIALNUM_EN               \</span><br><span style="color: hsl(0, 100%, 40%);">-        + CONF_USB_CDCD_ACM_ICONFIG_EN))</span><br><span style="color: hsl(120, 100%, 40%);">+// <o> bNumInterfaces <0x01-0xFF></span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_bnuminterfaces</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BNUMINTERFACES</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BNUMINTERFACES 1</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+// <o> bConfigurationValue <0x01-0xFF></span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_bconfigval</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BCONFIGVAL</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BCONFIGVAL 0x1</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+// <e> Enable string descriptor of iConfig</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_iconfig_en</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_ICONFIG_EN</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_ICONFIG_EN 0</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_ICONFIG</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_ICONFIG                                                                                      \</span><br><span style="color: hsl(120, 100%, 40%);">+ (CONF_USB_DFUD_ICONFIG_EN                                                                                      \</span><br><span style="color: hsl(120, 100%, 40%);">+       * (CONF_USB_DFUD_IMANUFACT_EN + CONF_USB_DFUD_IPRODUCT_EN + CONF_USB_DFUD_ISERIALNUM_EN               \</span><br><span style="color: hsl(120, 100%, 40%);">+          + CONF_USB_DFUD_ICONFIG_EN))</span><br><span> #endif</span><br><span> </span><br><span> // <s> Unicode string of iConfig</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_iconfig_str</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_ICONFIG_STR</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_ICONFIG_STR ""</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_iconfig_str</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_ICONFIG_STR</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_ICONFIG_STR ""</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_ICONFIG_STR_DESC</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_ICONFIG_STR_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_ICONFIG_STR_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_ICONFIG_STR_DESC</span><br><span> #endif</span><br><span> </span><br><span> // </e></span><br><span>@@ -184,157 +221,62 @@</span><br><span> // <0xA0=> Bus power supply, support for remote wakeup</span><br><span> // <0xC0=> Self powered, not support for remote wakeup</span><br><span> // <0xE0=> Self powered, support for remote wakeup</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_bmattri</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_BMATTRI</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_BMATTRI 0x80</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_bmattri</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BMATTRI</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BMATTRI 0x80</span><br><span> #endif</span><br><span> </span><br><span> // <o> bMaxPower <0x00-0xFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_bmaxpower</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_BMAXPOWER</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_BMAXPOWER 0x32</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_bmaxpower</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BMAXPOWER</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BMAXPOWER 0x32</span><br><span> #endif</span><br><span> // </h></span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-// <h> CDC ACM Communication Interface Descriptor</span><br><span style="color: hsl(120, 100%, 40%);">+// <h> DFU Interface Descriptor</span><br><span> </span><br><span> // <o> bInterfaceNumber <0x00-0xFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_comm_bifcnum</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_COMM_BIFCNUM</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_COMM_BIFCNUM 0x0</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_bifcnum</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BIFCNUM</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BIFCNUM 0x0</span><br><span> #endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> // <o> bAlternateSetting <0x00-0xFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_comm_baltset</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_COMM_BALTSET</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_COMM_BALTSET 0x0</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_baltset</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BALTSET</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BALTSET 0x0</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-// <o> iInterface <0x00-0xFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_comm_iifc</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_COMM_IIFC</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_COMM_IIFC 0x0</span><br><span style="color: hsl(120, 100%, 40%);">+// <o> bNumEndpoints <0x00-0xFF></span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_bnumep</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_BNUMEP</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_BNUMEP 0x0</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-// <o> Interrupt IN Endpoint Address</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x81=> EndpointAddress = 0x81</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x82=> EndpointAddress = 0x82</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x83=> EndpointAddress = 0x83</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x84=> EndpointAddress = 0x84</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x85=> EndpointAddress = 0x85</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x86=> EndpointAddress = 0x86</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x87=> EndpointAddress = 0x87</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_epaddr</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_COMM_INT_EPADDR</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_COMM_INT_EPADDR 0x82</span><br><span style="color: hsl(120, 100%, 40%);">+// <e> Enable string descriptor of iInterface</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_iinterface_en</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_IINTERFACE_EN</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IINTERFACE_EN 1</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-// <o> Interrupt IN Endpoint wMaxPacketSize</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0008=> 8 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0010=> 16 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0020=> 32 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0040=> 64 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_comm_int_maxpksz</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_COMM_INT_MAXPKSZ</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_COMM_INT_MAXPKSZ 0x40</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_IINTERFACE</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IINTERFACE                                                                                      \</span><br><span style="color: hsl(120, 100%, 40%);">+     (CONF_USB_DFUD_IINTERFACE_EN                                                                                      \</span><br><span style="color: hsl(120, 100%, 40%);">+    * (CONF_USB_DFUD_IMANUFACT_EN + CONF_USB_DFUD_IPRODUCT_EN + CONF_USB_DFUD_ISERIALNUM_EN               \</span><br><span style="color: hsl(120, 100%, 40%);">+          + CONF_USB_DFUD_ICONFIG_EN + CONF_USB_DFUD_IINTERFACE_EN))</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-// <o> Interrupt IN Endpoint Interval <0x00-0xFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_comm_int_interval</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_COMM_INT_INTERVAL</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_COMM_INT_INTERVAL 0xa</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(0, 100%, 40%);">-// </h></span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-// <h> CDC ACM Data Interface Descriptor</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-// <o> bInterfaceNumber <0x00-0xFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_data_bifcnum</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_DATA_BIFCNUM</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_DATA_BIFCNUM 0x1</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(0, 100%, 40%);">-// <o> bAlternateSetting <0x00-0xFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_data_baltset</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_DATA_BALTSET</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_DATA_BALTSET 0x0</span><br><span style="color: hsl(120, 100%, 40%);">+// <s> Unicode string of iInterface</span><br><span style="color: hsl(120, 100%, 40%);">+// <id> usb_dufd_iinterface_str</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_IINTERFAGE_STR</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IINTERFACE_STR "SAM D5x/E5x DFU bootloader (DFU mode)"</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-// <o> iInterface <0x00-0xFF></span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_data_iifc</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_DATA_IIFC</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_DATA_IIFC 0x0</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef CONF_USB_DFUD_IINTERFACE_STR_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IINTERFACE_STR_DESC 76, 0x03, 'S', 0x00, 'A', 0x00, 'M', 0x00, ' ', 0x00, 'D', 0x00, '5', 0x00, 'x', 0x00, '/', 0x00, 'E', 0x00, '5',  0x00, 'x', 0x00, ' ', 0x00, 'D', 0x00, 'F', 0x00, 'U', 0x00, ' ', 0x00, 'b', 0x00, 'o', 0x00, 'o', 0x00, 't', 0x00, 'l', 0x00, 'o', 0x00, 'a', 0x00, 'd', 0x00, 'e', 0x00, 'r', 0x00, ' ', 0x00, '(', 0x00, 'D', 0x00, 'F', 0x00, 'U', 0x00, ' ', 0x00, 'm', 0x00, 'o', 0x00, 'd', 0x00, 'e', 0x00, ')', 0x00,</span><br><span> #endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-// <o> BULK IN Endpoint Address</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x81=> EndpointAddress = 0x81</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x82=> EndpointAddress = 0x82</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x83=> EndpointAddress = 0x83</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x84=> EndpointAddress = 0x84</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x85=> EndpointAddress = 0x85</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x86=> EndpointAddress = 0x86</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x87=> EndpointAddress = 0x87</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_data_bulkin_epaddr</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_DATA_BULKIN_EPADDR</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_DATA_BULKIN_EPADDR 0x81</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-// <o> BULK IN Endpoint wMaxPacketSize</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0008=> 8 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0010=> 16 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0020=> 32 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0040=> 64 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_data_builin_maxpksz</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_DATA_BULKIN_MAXPKSZ</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_DATA_BULKIN_MAXPKSZ 0x40</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-// <o> BULK IN Endpoint wMaxPacketSize for High Speed</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0008=> 8 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0010=> 16 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0020=> 32 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0040=> 64 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0080=> 128 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0100=> 256 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0200=> 512 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_data_builin_maxpksz_hs</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_DATA_BULKIN_MAXPKSZ_HS</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_DATA_BULKIN_MAXPKSZ_HS 0x200</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-// <o> BULK OUT Endpoint Address</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x01=> EndpointAddress = 0x01</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x02=> EndpointAddress = 0x02</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x03=> EndpointAddress = 0x03</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x04=> EndpointAddress = 0x04</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x05=> EndpointAddress = 0x05</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x06=> EndpointAddress = 0x06</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x07=> EndpointAddress = 0x07</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_data_bulkout_epaddr</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_DATA_BULKOUT_EPADDR</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_DATA_BULKOUT_EPADDR 0x1</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-// <o> BULK OUT Endpoint wMaxPacketSize</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0008=> 8 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0010=> 16 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0020=> 32 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0040=> 64 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_data_buckout_maxpksz</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_DATA_BULKOUT_MAXPKSZ</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_DATA_BULKOUT_MAXPKSZ 0x40</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-// <o> BULK OUT Endpoint wMaxPacketSize for High Speed</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0008=> 8 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0010=> 16 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0020=> 32 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0040=> 64 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0080=> 128 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0100=> 256 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <0x0200=> 512 bytes</span><br><span style="color: hsl(0, 100%, 40%);">-// <id> usb_cdcd_acm_data_buckout_maxpksz_hs</span><br><span style="color: hsl(0, 100%, 40%);">-#ifndef CONF_USB_CDCD_ACM_DATA_BULKOUT_MAXPKSZ_HS</span><br><span style="color: hsl(0, 100%, 40%);">-#define CONF_USB_CDCD_ACM_DATA_BULKOUT_MAXPKSZ_HS 0x200</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(120, 100%, 40%);">+// </e></span><br><span> // </h></span><br><span> </span><br><span> // <<< end of configuration section >>></span><br><span>diff --git a/gcc/Makefile b/gcc/Makefile</span><br><span>index 6542661..231ed39 100644</span><br><span>--- a/gcc/Makefile</span><br><span>+++ b/gcc/Makefile</span><br><span>@@ -31,7 +31,7 @@</span><br><span> hpl/osc32kctrl \</span><br><span> hpl/ramecc \</span><br><span> hpl/dmac \</span><br><span style="color: hsl(0, 100%, 40%);">-usb/class/cdc/device \</span><br><span style="color: hsl(120, 100%, 40%);">+usb/class/dfu/device \</span><br><span> hal/src \</span><br><span> hpl/mclk \</span><br><span> usb \</span><br><span>@@ -49,7 +49,7 @@</span><br><span> OBJS +=  \</span><br><span> hal/src/hal_io.o \</span><br><span> hpl/core/hpl_core_m4.o \</span><br><span style="color: hsl(0, 100%, 40%);">-usb/class/cdc/device/cdcdf_acm.o \</span><br><span style="color: hsl(120, 100%, 40%);">+usb/class/dfu/device/dfudf.o \</span><br><span> hal/utils/src/utils_syscalls.o \</span><br><span> hpl/dmac/hpl_dmac.o \</span><br><span> gcc/system_same54.o \</span><br><span>@@ -77,14 +77,14 @@</span><br><span> hal/src/hal_cache.o \</span><br><span> hpl/cmcc/hpl_cmcc.o \</span><br><span> atmel_start.o \</span><br><span style="color: hsl(0, 100%, 40%);">-usb_cdc_echo_main.o \</span><br><span style="color: hsl(120, 100%, 40%);">+usb_dfu_main.o \</span><br><span> usb/device/usbdc.o \</span><br><span> hal/src/hal_atomic.o</span><br><span> </span><br><span> OBJS_AS_ARGS +=  \</span><br><span> "hal/src/hal_io.o" \</span><br><span> "hpl/core/hpl_core_m4.o" \</span><br><span style="color: hsl(0, 100%, 40%);">-"usb/class/cdc/device/cdcdf_acm.o" \</span><br><span style="color: hsl(120, 100%, 40%);">+"usb/class/dfu/device/dfudf.o" \</span><br><span> "hal/utils/src/utils_syscalls.o" \</span><br><span> "hpl/dmac/hpl_dmac.o" \</span><br><span> "gcc/system_same54.o" \</span><br><span>@@ -112,7 +112,7 @@</span><br><span> "hal/src/hal_cache.o" \</span><br><span> "hpl/cmcc/hpl_cmcc.o" \</span><br><span> "atmel_start.o" \</span><br><span style="color: hsl(0, 100%, 40%);">-"usb_cdc_echo_main.o" \</span><br><span style="color: hsl(120, 100%, 40%);">+"usb_dfu_main.o" \</span><br><span> "usb/device/usbdc.o" \</span><br><span> "hal/src/hal_atomic.o"</span><br><span> </span><br><span>@@ -125,7 +125,7 @@</span><br><span> "hpl/ramecc/hpl_ramecc.d" \</span><br><span> "hpl/core/hpl_core_m4.d" \</span><br><span> "hal/utils/src/utils_syscalls.d" \</span><br><span style="color: hsl(0, 100%, 40%);">-"usb/class/cdc/device/cdcdf_acm.d" \</span><br><span style="color: hsl(120, 100%, 40%);">+"usb/class/dfu/device/dfudf.d" \</span><br><span> "gcc/gcc/startup_same54.d" \</span><br><span> "hpl/usb/hpl_usb.d" \</span><br><span> "hal/utils/src/utils_list.d" \</span><br><span>@@ -140,7 +140,7 @@</span><br><span> "hal/src/hal_usb_device.d" \</span><br><span> "hpl/dmac/hpl_dmac.d" \</span><br><span> "hal/src/hal_init.d" \</span><br><span style="color: hsl(0, 100%, 40%);">-"usb_cdc_echo_main.d" \</span><br><span style="color: hsl(120, 100%, 40%);">+"usb_dfu_main.d" \</span><br><span> "hpl/mclk/hpl_mclk.d" \</span><br><span> "driver_init.d" \</span><br><span> "hpl/osc32kctrl/hpl_osc32kctrl.d" \</span><br><span>@@ -199,7 +199,7 @@</span><br><span>   @echo ARM/GNU C Compiler</span><br><span>     $(QUOTE)arm-none-eabi-gcc$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \</span><br><span> -D__SAME54P20A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \</span><br><span style="color: hsl(0, 100%, 40%);">--I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span style="color: hsl(120, 100%, 40%);">+-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/dfu" -I"../usb/class/dfu/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span> -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"  -o "$@" "$<"</span><br><span>        @echo Finished building: $<</span><br><span> </span><br><span>@@ -208,7 +208,7 @@</span><br><span>     @echo ARM/GNU Assembler</span><br><span>      $(QUOTE)arm-none-eabi-as$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \</span><br><span> -D__SAME54P20A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \</span><br><span style="color: hsl(0, 100%, 40%);">--I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span style="color: hsl(120, 100%, 40%);">+-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/dfu" -I"../usb/class/dfu/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span> -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"  -o "$@" "$<"</span><br><span>         @echo Finished building: $<</span><br><span> </span><br><span>@@ -217,7 +217,7 @@</span><br><span>     @echo ARM/GNU Preprocessing Assembler</span><br><span>        $(QUOTE)arm-none-eabi-gcc$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \</span><br><span> -D__SAME54P20A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \</span><br><span style="color: hsl(0, 100%, 40%);">--I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/cdc" -I"../usb/class/cdc/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span style="color: hsl(120, 100%, 40%);">+-I"../" -I"../config" -I"../examples" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/dfu" -I"../usb/class/dfu/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span> -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"  -o "$@" "$<"</span><br><span>        @echo Finished building: $<</span><br><span> </span><br><span>@@ -237,4 +237,4 @@</span><br><span>     rm -f $(DEPS_AS_ARGS)</span><br><span>        rm -f $(OUTPUT_FILE_NAME).a $(OUTPUT_FILE_NAME).hex $(OUTPUT_FILE_NAME).bin \</span><br><span>         $(OUTPUT_FILE_NAME).lss $(OUTPUT_FILE_NAME).eep $(OUTPUT_FILE_NAME).map \</span><br><span style="color: hsl(0, 100%, 40%);">-        $(OUTPUT_FILE_NAME).srec</span><br><span>\ No newline at end of file</span><br><span style="color: hsl(120, 100%, 40%);">+        $(OUTPUT_FILE_NAME).srec</span><br><span>diff --git a/usb/class/dfu/device/dfudf.c b/usb/class/dfu/device/dfudf.c</span><br><span>new file mode 100644</span><br><span>index 0000000..7747a23</span><br><span>--- /dev/null</span><br><span>+++ b/usb/class/dfu/device/dfudf.c</span><br><span>@@ -0,0 +1,186 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief USB Device Stack DFU Function Implementation.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2018 sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This library is free software; you can redistribute it and/or</span><br><span style="color: hsl(120, 100%, 40%);">+ * modify it under the terms of the GNU Lesser General Public</span><br><span style="color: hsl(120, 100%, 40%);">+ * License as published by the Free Software Foundation; either</span><br><span style="color: hsl(120, 100%, 40%);">+ * version 2.1 of the License, or (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This library is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span><br><span style="color: hsl(120, 100%, 40%);">+ * Lesser General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU Lesser General Public</span><br><span style="color: hsl(120, 100%, 40%);">+ * License along with this library; if not, write to the Free Software</span><br><span style="color: hsl(120, 100%, 40%);">+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include "dfudf.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "usb_protocol_dfu.h"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/** USB Device DFU Fucntion Specific Data */</span><br><span style="color: hsl(120, 100%, 40%);">+struct dfudf_func_data {</span><br><span style="color: hsl(120, 100%, 40%);">+   /** DFU Interface information */</span><br><span style="color: hsl(120, 100%, 40%);">+      uint8_t func_iface;</span><br><span style="color: hsl(120, 100%, 40%);">+   /** DFU Enable Flag */</span><br><span style="color: hsl(120, 100%, 40%);">+        bool enabled;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static struct usbdf_driver _dfudf;</span><br><span style="color: hsl(120, 100%, 40%);">+static struct dfudf_func_data _dfudf_funcd;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Enable DFU Function</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] drv Pointer to USB device function driver</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] desc Pointer to USB interface descriptor</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return Operation status.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+static int32_t dfudf_enable(struct usbdf_driver *drv, struct usbd_descriptors *desc)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       struct dfudf_func_data *func_data = (struct dfudf_func_data *)(drv->func_data);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  usb_iface_desc_t ifc_desc;</span><br><span style="color: hsl(120, 100%, 40%);">+    uint8_t *        ifc;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint8_t          i;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ifc = desc->sod;</span><br><span style="color: hsl(120, 100%, 40%);">+   for (i = 0; i < 2; i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+          if (NULL == ifc) {</span><br><span style="color: hsl(120, 100%, 40%);">+                    return ERR_NOT_FOUND;</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           ifc_desc.bInterfaceNumber = ifc[2];</span><br><span style="color: hsl(120, 100%, 40%);">+           ifc_desc.bInterfaceClass  = ifc[5];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+         if (USB_DFU_CLASS == ifc_desc.bInterfaceClass) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      if (func_data->func_iface == ifc_desc.bInterfaceNumber) { // Initialized</span><br><span style="color: hsl(120, 100%, 40%);">+                           return ERR_ALREADY_INITIALIZED;</span><br><span style="color: hsl(120, 100%, 40%);">+                       } else if (func_data->func_iface != 0xFF) { // Occupied</span><br><span style="color: hsl(120, 100%, 40%);">+                            return ERR_NO_RESOURCE;</span><br><span style="color: hsl(120, 100%, 40%);">+                       } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                              func_data->func_iface = ifc_desc.bInterfaceNumber;</span><br><span style="color: hsl(120, 100%, 40%);">+                 }</span><br><span style="color: hsl(120, 100%, 40%);">+             } else { // Not supported by this function driver</span><br><span style="color: hsl(120, 100%, 40%);">+                     return ERR_NOT_FOUND;</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           // there are no endpoint to install since DFU uses only the control endpoint</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                ifc = usb_find_desc(usb_desc_next(desc->sod), desc->eod, USB_DT_INTERFACE);</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+     // Installed</span><br><span style="color: hsl(120, 100%, 40%);">+  _dfudf_funcd.enabled = true;</span><br><span style="color: hsl(120, 100%, 40%);">+  return ERR_NONE;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Disable DFU Function</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] drv Pointer to USB device function driver</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] desc Pointer to USB device descriptor</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return Operation status.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+static int32_t dfudf_disable(struct usbdf_driver *drv, struct usbd_descriptors *desc)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct dfudf_func_data *func_data = (struct dfudf_func_data *)(drv->func_data);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  usb_iface_desc_t ifc_desc;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  if (desc) {</span><br><span style="color: hsl(120, 100%, 40%);">+           ifc_desc.bInterfaceClass = desc->sod[5];</span><br><span style="color: hsl(120, 100%, 40%);">+           // Check interface</span><br><span style="color: hsl(120, 100%, 40%);">+            if (ifc_desc.bInterfaceClass != USB_DFU_CLASS) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      return ERR_NOT_FOUND;</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   func_data->func_iface = 0xFF;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    _dfudf_funcd.enabled = false;</span><br><span style="color: hsl(120, 100%, 40%);">+ return ERR_NONE;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief DFU Control Function</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] drv Pointer to USB device function driver</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] ctrl USB device general function control type</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] param Parameter pointer</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return Operation status.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+static int32_t dfudf_ctrl(struct usbdf_driver *drv, enum usbdf_control ctrl, void *param)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      switch (ctrl) {</span><br><span style="color: hsl(120, 100%, 40%);">+       case USBDF_ENABLE:</span><br><span style="color: hsl(120, 100%, 40%);">+            return dfudf_enable(drv, (struct usbd_descriptors *)param);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ case USBDF_DISABLE:</span><br><span style="color: hsl(120, 100%, 40%);">+           return dfudf_disable(drv, (struct usbd_descriptors *)param);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        case USBDF_GET_IFACE:</span><br><span style="color: hsl(120, 100%, 40%);">+         return ERR_UNSUPPORTED_OP;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  default:</span><br><span style="color: hsl(120, 100%, 40%);">+              return ERR_INVALID_ARG;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Process the CDC class request</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] ep Endpoint address.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param[in] req Pointer to the request.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return Operation status.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+static int32_t dfudf_req(uint8_t ep, struct usb_req *req, enum usb_ctrl_stage stage)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       if (0x01 != ((req->bmRequestType >> 5) & 0x03)) { // class request</span><br><span style="color: hsl(120, 100%, 40%);">+               return ERR_NOT_FOUND;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+     if ((req->wIndex == _dfudf_funcd.func_iface)) {</span><br><span style="color: hsl(120, 100%, 40%);">+            // we don't verify the bmRequestType</span><br><span style="color: hsl(120, 100%, 40%);">+              switch (req->bRequest) {</span><br><span style="color: hsl(120, 100%, 40%);">+           default:</span><br><span style="color: hsl(120, 100%, 40%);">+                      return ERR_UNSUPPORTED_OP;</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+     } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              return ERR_NOT_FOUND;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/** USB Device DFU Handler Struct */</span><br><span style="color: hsl(120, 100%, 40%);">+static struct usbdc_handler dfudf_req_h = {NULL, (FUNC_PTR)dfudf_req};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Initialize the USB DFU Function Driver</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int32_t dfudf_init(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       if (usbdc_get_state() > USBD_S_POWER) {</span><br><span style="color: hsl(120, 100%, 40%);">+            return ERR_DENIED;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   _dfudf.ctrl      = dfudf_ctrl;</span><br><span style="color: hsl(120, 100%, 40%);">+        _dfudf.func_data = &_dfudf_funcd;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       usbdc_register_function(&_dfudf);</span><br><span style="color: hsl(120, 100%, 40%);">+ usbdc_register_handler(USBDC_HDL_REQ, &dfudf_req_h);</span><br><span style="color: hsl(120, 100%, 40%);">+      return ERR_NONE;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Deinitialize the USB DFU Function Driver</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void dfudf_deinit(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Check whether DFU Function is enabled</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+bool dfudf_is_enabled(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       return _dfudf_funcd.enabled;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/usb_cdc_echo_main.c b/usb/class/dfu/device/dfudf.h</span><br><span>similarity index 62%</span><br><span>copy from usb_cdc_echo_main.c</span><br><span>copy to usb/class/dfu/device/dfudf.h</span><br><span>index fe02810..ba5cdd5 100644</span><br><span>--- a/usb_cdc_echo_main.c</span><br><span>+++ b/usb/class/dfu/device/dfudf.h</span><br><span>@@ -1,9 +1,10 @@</span><br><span> /**</span><br><span>  * \file</span><br><span>  *</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief Application implement</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief USB Device Stack DFU Function Definition.</span><br><span>  *</span><br><span>  * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2018 sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de></span><br><span>  *</span><br><span>  * \asf_license_start</span><br><span>  *</span><br><span>@@ -15,7 +16,7 @@</span><br><span>  * to your use of third party software (including open source software) that</span><br><span>  * may accompany Microchip software.</span><br><span>  *</span><br><span style="color: hsl(0, 100%, 40%);">- * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS".  NO WARRANTIES,</span><br><span style="color: hsl(120, 100%, 40%);">+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,</span><br><span>  * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,</span><br><span>  * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,</span><br><span>  * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE</span><br><span>@@ -28,17 +29,31 @@</span><br><span>  * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.</span><br><span>  *</span><br><span>  * \asf_license_stop</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-/*</span><br><span style="color: hsl(0, 100%, 40%);">- * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a></span><br><span>  */</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#include "atmel_start.h"</span><br><span style="color: hsl(0, 100%, 40%);">-#include "atmel_start_pins.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef USBDF_DFU_H_</span><br><span style="color: hsl(120, 100%, 40%);">+#define USBDF_DFU_H_</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-int main(void)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-       atmel_start_init();</span><br><span style="color: hsl(0, 100%, 40%);">-     cdcd_acm_example();</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(120, 100%, 40%);">+#include "usbdc.h"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Initialize the USB DFU Function Driver</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return Operation status.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int32_t dfudf_init(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Deinitialize the USB DFU Function Driver</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return Operation status.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void dfudf_deinit(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Check whether DFU Function is enabled</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return Operation status.</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return true DFU Function is enabled</span><br><span style="color: hsl(120, 100%, 40%);">+ * \return false DFU Function is disabled</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+bool dfudf_is_enabled(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* USBDF_DFU_H_ */</span><br><span>diff --git a/usb/class/dfu/device/dfudf_desc.h b/usb/class/dfu/device/dfudf_desc.h</span><br><span>new file mode 100644</span><br><span>index 0000000..f9eca38</span><br><span>--- /dev/null</span><br><span>+++ b/usb/class/dfu/device/dfudf_desc.h</span><br><span>@@ -0,0 +1,112 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief USB Device Stack DFU Function Descriptor Setting.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2018 sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_start</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \page License</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Subject to your compliance with these terms, you may use Microchip</span><br><span style="color: hsl(120, 100%, 40%);">+ * software and any derivatives exclusively with Microchip products.</span><br><span style="color: hsl(120, 100%, 40%);">+ * It is your responsibility to comply with third party license terms applicable</span><br><span style="color: hsl(120, 100%, 40%);">+ * to your use of third party software (including open source software) that</span><br><span style="color: hsl(120, 100%, 40%);">+ * may accompany Microchip software.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,</span><br><span style="color: hsl(120, 100%, 40%);">+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,</span><br><span style="color: hsl(120, 100%, 40%);">+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE</span><br><span style="color: hsl(120, 100%, 40%);">+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL</span><br><span style="color: hsl(120, 100%, 40%);">+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE</span><br><span style="color: hsl(120, 100%, 40%);">+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT</span><br><span style="color: hsl(120, 100%, 40%);">+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY</span><br><span style="color: hsl(120, 100%, 40%);">+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,</span><br><span style="color: hsl(120, 100%, 40%);">+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \asf_license_stop</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef USBDF_DFU_DESC_H_</span><br><span style="color: hsl(120, 100%, 40%);">+#define USBDF_DFU_DESC_H_</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include "usb_protocol.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "usbd_config.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "usb_protocol_dfu.h"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define DFUD_DEV_DESC \</span><br><span style="color: hsl(120, 100%, 40%);">+   USB_DEV_DESC_BYTES(CONF_USB_DFUD_BCDUSB, \</span><br><span style="color: hsl(120, 100%, 40%);">+                       CONF_USB_DFUD_BDEVICECLASS, \</span><br><span style="color: hsl(120, 100%, 40%);">+                         CONF_USB_DFUD_BDEVICESUBCLASS, \</span><br><span style="color: hsl(120, 100%, 40%);">+                      CONF_USB_DFUD_BDEVICEPROTOCOL, \</span><br><span style="color: hsl(120, 100%, 40%);">+                      CONF_USB_DFUD_BMAXPKSZ0, \</span><br><span style="color: hsl(120, 100%, 40%);">+                    CONF_USB_OCTSIM_IDVENDOR, \</span><br><span style="color: hsl(120, 100%, 40%);">+                           CONF_USB_OCTSIM_IDPRODUCT, \</span><br><span style="color: hsl(120, 100%, 40%);">+                          CONF_USB_DFUD_BCDDEVICE, \</span><br><span style="color: hsl(120, 100%, 40%);">+                    CONF_USB_DFUD_IMANUFACT, \</span><br><span style="color: hsl(120, 100%, 40%);">+                    CONF_USB_DFUD_IPRODUCT, \</span><br><span style="color: hsl(120, 100%, 40%);">+                     CONF_USB_DFUD_ISERIALNUM, \</span><br><span style="color: hsl(120, 100%, 40%);">+                           CONF_USB_DFUD_BNUMCONFIG)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define DFUD_DEV_QUAL_DESC \</span><br><span style="color: hsl(120, 100%, 40%);">+  USB_DEV_QUAL_DESC_BYTES(CONF_USB_DFUD_BCDUSB, \</span><br><span style="color: hsl(120, 100%, 40%);">+                               CONF_USB_DFUD_BDEVICECLASS, \</span><br><span style="color: hsl(120, 100%, 40%);">+                         CONF_USB_DFUD_BDEVICESUBCLASS, \</span><br><span style="color: hsl(120, 100%, 40%);">+                              CONF_USB_DFUD_BMAXPKSZ0, \</span><br><span style="color: hsl(120, 100%, 40%);">+                            CONF_USB_DFUD_BNUMCONFIG)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define DFUD_CFG_DESC \</span><br><span style="color: hsl(120, 100%, 40%);">+  USB_CONFIG_DESC_BYTES(CONF_USB_DFUD_WTOTALLENGTH, \</span><br><span style="color: hsl(120, 100%, 40%);">+                         CONF_USB_DFUD_BNUMINTERFACES, \</span><br><span style="color: hsl(120, 100%, 40%);">+                       CONF_USB_DFUD_BCONFIGVAL, \</span><br><span style="color: hsl(120, 100%, 40%);">+                           CONF_USB_DFUD_ICONFIG, \</span><br><span style="color: hsl(120, 100%, 40%);">+                              CONF_USB_DFUD_BMATTRI, \</span><br><span style="color: hsl(120, 100%, 40%);">+                              CONF_USB_DFUD_BMAXPOWER)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define DFUD_OTH_SPD_CFG_DESC \</span><br><span style="color: hsl(120, 100%, 40%);">+     USB_OTH_SPD_CFG_DESC_BYTES(CONF_USB_DFUD_WTOTALLENGTH, \</span><br><span style="color: hsl(120, 100%, 40%);">+                                 CONF_USB_DFUD_BNUMINTERFACES, \</span><br><span style="color: hsl(120, 100%, 40%);">+                               CONF_USB_DFUD_BCONFIGVAL, \</span><br><span style="color: hsl(120, 100%, 40%);">+                                   CONF_USB_DFUD_ICONFIG, \</span><br><span style="color: hsl(120, 100%, 40%);">+                              CONF_USB_DFUD_BMATTRI, \</span><br><span style="color: hsl(120, 100%, 40%);">+                              CONF_USB_DFUD_BMAXPOWER)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define DFUD_IFACE_DESCES \</span><br><span style="color: hsl(120, 100%, 40%);">+    USB_IFACE_DESC_BYTES(CONF_USB_DFUD_BIFCNUM, \</span><br><span style="color: hsl(120, 100%, 40%);">+                      CONF_USB_DFUD_BALTSET, \</span><br><span style="color: hsl(120, 100%, 40%);">+                      CONF_USB_DFUD_BNUMEP, \</span><br><span style="color: hsl(120, 100%, 40%);">+                       USB_DFU_CLASS, \</span><br><span style="color: hsl(120, 100%, 40%);">+                      USB_DFU_SUBCLASS, \</span><br><span style="color: hsl(120, 100%, 40%);">+                           USB_DFU_PROTOCOL_DFU, \</span><br><span style="color: hsl(120, 100%, 40%);">+                       CONF_USB_DFUD_IINTERFACE), \</span><br><span style="color: hsl(120, 100%, 40%);">+                          USB_DFU_FUNC_DESC_BYTES(USB_DFU_ATTRIBUTES_CAN_DOWNLOAD | USB_DFU_ATTRIBUTES_WILL_DETACH, \</span><br><span style="color: hsl(120, 100%, 40%);">+                                                   200, /* maximum time in milliseconds to detach (and reboot) */ \</span><br><span style="color: hsl(120, 100%, 40%);">+                                              1024, /* maximum transfer size */ \</span><br><span style="color: hsl(120, 100%, 40%);">+                                                   0x0110 /*< DFU specification version 1.1 used */ )</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define DFUD_STR_DESCES \</span><br><span style="color: hsl(120, 100%, 40%);">+       CONF_USB_DFUD_LANGID_DESC \</span><br><span style="color: hsl(120, 100%, 40%);">+   CONF_USB_DFUD_IMANUFACT_STR_DESC \</span><br><span style="color: hsl(120, 100%, 40%);">+    CONF_USB_DFUD_IPRODUCT_STR_DESC \</span><br><span style="color: hsl(120, 100%, 40%);">+     CONF_USB_DFUD_ISERIALNUM_STR_DESC \</span><br><span style="color: hsl(120, 100%, 40%);">+   CONF_USB_DFUD_ICONFIG_STR_DESC \</span><br><span style="color: hsl(120, 100%, 40%);">+      CONF_USB_DFUD_IINTERFACE_STR_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/** USB Device descriptors and configuration descriptors */</span><br><span style="color: hsl(120, 100%, 40%);">+#define DFUD_DESCES_LS_FS \</span><br><span style="color: hsl(120, 100%, 40%);">+ DFUD_DEV_DESC, DFUD_CFG_DESC, DFUD_IFACE_DESCES, DFUD_STR_DESCES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define DFUD_HS_DESCES_LS_FS \</span><br><span style="color: hsl(120, 100%, 40%);">+    DFUD_DEV_DESC, DFUD_DEV_QUAL_DESC, DFUD_CFG_DESC, DFUD_M_IFACE_DESCES, \</span><br><span style="color: hsl(120, 100%, 40%);">+          DFUD_IFACE_DESCES, DFUD_OTH_SPD_CFG_DESC, \</span><br><span style="color: hsl(120, 100%, 40%);">+           DFUD_IFACE_DESCES_HS, DFUD_STR_DESCES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define DFUD_HS_DESCES_HS \</span><br><span style="color: hsl(120, 100%, 40%);">+      DFUD_CFG_DESC, DFUD_IFACE_DESCES, DFUD_IFACE_DESCES_HS, DFUD_OTH_SPD_CFG_DESC, \</span><br><span style="color: hsl(120, 100%, 40%);">+          DFUD_IFACE_DESCES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* USBDF_DFU_DESC_H_ */</span><br><span>diff --git a/usb/class/dfu/usb_protocol_dfu.h b/usb/class/dfu/usb_protocol_dfu.h</span><br><span>new file mode 100644</span><br><span>index 0000000..2e7323f</span><br><span>--- /dev/null</span><br><span>+++ b/usb/class/dfu/usb_protocol_dfu.h</span><br><span>@@ -0,0 +1,150 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \file</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief USB Device Firmware Upgrade (DFU) protocol definitions</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2018 sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This library is free software; you can redistribute it and/or</span><br><span style="color: hsl(120, 100%, 40%);">+ * modify it under the terms of the GNU Lesser General Public</span><br><span style="color: hsl(120, 100%, 40%);">+ * License as published by the Free Software Foundation; either</span><br><span style="color: hsl(120, 100%, 40%);">+ * version 2.1 of the License, or (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This library is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span><br><span style="color: hsl(120, 100%, 40%);">+ * Lesser General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU Lesser General Public</span><br><span style="color: hsl(120, 100%, 40%);">+ * License along with this library; if not, write to the Free Software</span><br><span style="color: hsl(120, 100%, 40%);">+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef _USB_PROTOCOL_DFU_H_</span><br><span style="color: hsl(120, 100%, 40%);">+#define _USB_PROTOCOL_DFU_H_</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include "usb_includes.h"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * \ingroup usb_protocol_group</span><br><span style="color: hsl(120, 100%, 40%);">+ * \defgroup dfu_protocol_group Device Firmware Upgrade Definitions</span><br><span style="color: hsl(120, 100%, 40%);">+ * \implements USB Device Firmware Upgrade Specification, Revision 1.1</span><br><span style="color: hsl(120, 100%, 40%);">+ * @{</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \name USB DFU Subclass IDs</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+//@{</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_DFU_CLASS 0xFE //!< Application Specific Class Code</span><br><span style="color: hsl(120, 100%, 40%);">+//@}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+//! \name USB DFU Subclass IDs</span><br><span style="color: hsl(120, 100%, 40%);">+//@{</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_DFU_SUBCLASS 0x01 //!< Device Firmware Upgrade Code</span><br><span style="color: hsl(120, 100%, 40%);">+//@}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+//! \name USB DFU Protocol IDs</span><br><span style="color: hsl(120, 100%, 40%);">+//@{</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_DFU_PROTOCOL_RUNTIME 0x01 //!< Runtime protocol</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_DFU_PROTOCOL_DFU 0x02 //!< DFU mode protocol</span><br><span style="color: hsl(120, 100%, 40%);">+//@}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+//! \name USB DFU Attributes bits mask</span><br><span style="color: hsl(120, 100%, 40%);">+//@{</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_DFU_ATTRIBUTES_CAN_DOWNLOAD 0x01</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_DFU_ATTRIBUTES_CAN_UPLOAD 0x02</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_DFU_ATTRIBUTES_MANIFEST_TOLERANT 0x04</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_DFU_ATTRIBUTES_WILL_DETACH 0x08</span><br><span style="color: hsl(120, 100%, 40%);">+//@}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+//! \name USB DFU Request IDs</span><br><span style="color: hsl(120, 100%, 40%);">+//@{</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_REQ_DFU_DETACH 0x00</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_REQ_DFU_DNLOAD 0x01</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_REQ_DFU_UPLOAD 0x02</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_REQ_DFU_GETSTATUS 0x03</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_REQ_DFU_CLRSTATUS 0x04</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_REQ_DFU_GETSTATE 0x05</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_REQ_DFU_ABORT 0x06</span><br><span style="color: hsl(120, 100%, 40%);">+//@}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Need to pack structures tightly, or the compiler might insert padding</span><br><span style="color: hsl(120, 100%, 40%);">+ * and violate the spec-mandated layout.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+COMPILER_PACK_SET(1)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+//! \name USB DFU Descriptors</span><br><span style="color: hsl(120, 100%, 40%);">+//@{</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+//! DFU Functional Descriptor</span><br><span style="color: hsl(120, 100%, 40%);">+typedef struct usb_dfu_func_desc {</span><br><span style="color: hsl(120, 100%, 40%);">+      uint8_t bFunctionLength;</span><br><span style="color: hsl(120, 100%, 40%);">+      uint8_t bDescriptorType;</span><br><span style="color: hsl(120, 100%, 40%);">+      uint8_t bmAttributes;</span><br><span style="color: hsl(120, 100%, 40%);">+ le16_t  wDetachTimeOut;</span><br><span style="color: hsl(120, 100%, 40%);">+       le16_t  wTransferSize;</span><br><span style="color: hsl(120, 100%, 40%);">+        le16_t  bcdDFUVersion;</span><br><span style="color: hsl(120, 100%, 40%);">+} usb_dfu_func_desc_t;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_DFU_FUNC_DESC_LEN 0x09</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_DFU_FUNC_DESC_TYPE 0x21</span><br><span style="color: hsl(120, 100%, 40%);">+#define USB_DFU_FUNC_DESC_BYTES(bmAttributes, wDetachTimeOut, wTransferSize, bcdDFUVersion) \</span><br><span style="color: hsl(120, 100%, 40%);">+      USB_DFU_FUNC_DESC_LEN, /* bFunctionLength */ \</span><br><span style="color: hsl(120, 100%, 40%);">+        USB_DFU_FUNC_DESC_TYPE, /* bDescriptorType */ \</span><br><span style="color: hsl(120, 100%, 40%);">+       bmAttributes, \</span><br><span style="color: hsl(120, 100%, 40%);">+       LE_BYTE0(wDetachTimeOut), LE_BYTE1(wDetachTimeOut), \</span><br><span style="color: hsl(120, 100%, 40%);">+ LE_BYTE0(wTransferSize), LE_BYTE1(wTransferSize), \</span><br><span style="color: hsl(120, 100%, 40%);">+   LE_BYTE0(bcdDFUVersion), LE_BYTE1(bcdDFUVersion)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+COMPILER_PACK_RESET()</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+//! @}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+//! USB DFU Request IDs</span><br><span style="color: hsl(120, 100%, 40%);">+enum usb_dfu_req {</span><br><span style="color: hsl(120, 100%, 40%);">+    USB_DFU_DETACH,</span><br><span style="color: hsl(120, 100%, 40%);">+       USB_DFU_DNLOAD,</span><br><span style="color: hsl(120, 100%, 40%);">+       USB_DFU_UPLOAD,</span><br><span style="color: hsl(120, 100%, 40%);">+       USB_DFU_GETSTATUS,</span><br><span style="color: hsl(120, 100%, 40%);">+    USB_DFU_CLRSTATUS,</span><br><span style="color: hsl(120, 100%, 40%);">+    USB_DFU_GETSTATE,</span><br><span style="color: hsl(120, 100%, 40%);">+     USB_DFU_ABORT,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+//! USB DFU Device Status IDs</span><br><span style="color: hsl(120, 100%, 40%);">+enum usb_dfu_status {</span><br><span style="color: hsl(120, 100%, 40%);">+    USB_DFU_STATUS_OK,</span><br><span style="color: hsl(120, 100%, 40%);">+    USB_DFU_STATUS_ERR_TARGET,</span><br><span style="color: hsl(120, 100%, 40%);">+    USB_DFU_STATUS_ERR_FILE,</span><br><span style="color: hsl(120, 100%, 40%);">+      USB_DFU_STATUS_ERR_WRITE,</span><br><span style="color: hsl(120, 100%, 40%);">+     USB_DFU_STATUS_ERR_ERASE,</span><br><span style="color: hsl(120, 100%, 40%);">+     USB_DFU_STATUS_ERR_CHECK_ERASED,</span><br><span style="color: hsl(120, 100%, 40%);">+      USB_DFU_STATUS_ERR_PROG,</span><br><span style="color: hsl(120, 100%, 40%);">+      USB_DFU_STATUS_ERR_VERIFY,</span><br><span style="color: hsl(120, 100%, 40%);">+    USB_DFU_STATUS_ERR_ADDRESS,</span><br><span style="color: hsl(120, 100%, 40%);">+   USB_DFU_STATUS_ERR_NOTDONE,</span><br><span style="color: hsl(120, 100%, 40%);">+   USB_DFU_STATUS_ERR_FIRMWARE,</span><br><span style="color: hsl(120, 100%, 40%);">+  USB_DFU_STATUS_ERR_VENDOR,</span><br><span style="color: hsl(120, 100%, 40%);">+    USB_DFU_STATUS_ERR_USBR,</span><br><span style="color: hsl(120, 100%, 40%);">+      USB_DFU_STATUS_ERR_POR,</span><br><span style="color: hsl(120, 100%, 40%);">+       USB_DFU_STATUS_ERR_UNKNOWN,</span><br><span style="color: hsl(120, 100%, 40%);">+   USB_DFU_STATUS_ERR_STALLEDPKT,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+//! USB DFU Device State IDs</span><br><span style="color: hsl(120, 100%, 40%);">+enum usb_dfu_state {</span><br><span style="color: hsl(120, 100%, 40%);">+      USB_DFU_STATE_APP_IDLE,</span><br><span style="color: hsl(120, 100%, 40%);">+       USB_DFU_STATE_APP_DETACH,</span><br><span style="color: hsl(120, 100%, 40%);">+     USB_DFU_STATE_DFU_IDLE,</span><br><span style="color: hsl(120, 100%, 40%);">+       USB_DFU_STATE_DFU_DNLOAD_SYNC,</span><br><span style="color: hsl(120, 100%, 40%);">+        USB_DFU_STATE_DFU_DNBUSY,</span><br><span style="color: hsl(120, 100%, 40%);">+     USB_DFU_STATE_DFU_DNLOAD_IDLE,</span><br><span style="color: hsl(120, 100%, 40%);">+        USB_DFU_STATE_DFU_MANIFEST_SYNC,</span><br><span style="color: hsl(120, 100%, 40%);">+      USB_DFU_STATE_DFU_MANIFEST,</span><br><span style="color: hsl(120, 100%, 40%);">+   USB_DFU_STATE_DFU_MANIFEST_WAIT_RESET,</span><br><span style="color: hsl(120, 100%, 40%);">+        USB_DFU_STATE_DFU_UPLOAD_IDLE,</span><br><span style="color: hsl(120, 100%, 40%);">+        USB_DFU_STATE_DFU_ERROR,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif // _USB_PROTOCOL_DFU_H_</span><br><span>diff --git a/usb_cdc_echo_main.c b/usb_dfu_main.c</span><br><span>similarity index 93%</span><br><span>rename from usb_cdc_echo_main.c</span><br><span>rename to usb_dfu_main.c</span><br><span>index fe02810..2535475 100644</span><br><span>--- a/usb_cdc_echo_main.c</span><br><span>+++ b/usb_dfu_main.c</span><br><span>@@ -4,6 +4,7 @@</span><br><span>  * \brief Application implement</span><br><span>  *</span><br><span>  * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2018 sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de></span><br><span>  *</span><br><span>  * \asf_license_start</span><br><span>  *</span><br><span>@@ -40,5 +41,5 @@</span><br><span> int main(void)</span><br><span> {</span><br><span>    atmel_start_init();</span><br><span style="color: hsl(0, 100%, 40%);">-     cdcd_acm_example();</span><br><span style="color: hsl(120, 100%, 40%);">+   usb_dfu();</span><br><span> }</span><br><span>diff --git a/usb_start.c b/usb_start.c</span><br><span>index de86172..4f9f875 100644</span><br><span>--- a/usb_start.c</span><br><span>+++ b/usb_start.c</span><br><span>@@ -1,9 +1,19 @@</span><br><span> /*</span><br><span style="color: hsl(0, 100%, 40%);">- * Code generated from Atmel Start.</span><br><span style="color: hsl(120, 100%, 40%);">+ * (C) 2018, sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de></span><br><span>  *</span><br><span style="color: hsl(0, 100%, 40%);">- * This file will be overwritten when reconfiguring your Atmel Start project.</span><br><span style="color: hsl(0, 100%, 40%);">- * Please copy examples or other code you want to keep to a separate file or main.c</span><br><span style="color: hsl(0, 100%, 40%);">- * to avoid loosing it when reconfiguring.</span><br><span style="color: hsl(120, 100%, 40%);">+ * This library is free software; you can redistribute it and/or</span><br><span style="color: hsl(120, 100%, 40%);">+ * modify it under the terms of the GNU Lesser General Public</span><br><span style="color: hsl(120, 100%, 40%);">+ * License as published by the Free Software Foundation; either</span><br><span style="color: hsl(120, 100%, 40%);">+ * version 2.1 of the License, or (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This library is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span><br><span style="color: hsl(120, 100%, 40%);">+ * Lesser General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU Lesser General Public</span><br><span style="color: hsl(120, 100%, 40%);">+ * License along with this library; if not, write to the Free Software</span><br><span style="color: hsl(120, 100%, 40%);">+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA</span><br><span>  */</span><br><span> #include "atmel_start.h"</span><br><span> #include "usb_start.h"</span><br><span>@@ -11,16 +21,14 @@</span><br><span> #if CONF_USBD_HS_SP</span><br><span> static uint8_t single_desc_bytes[] = {</span><br><span>     /* Device descriptors and Configuration descriptors list. */</span><br><span style="color: hsl(0, 100%, 40%);">-    CDCD_ACM_HS_DESCES_LS_FS};</span><br><span style="color: hsl(120, 100%, 40%);">+    DFUD_HS_DESCES_LS_FS};</span><br><span> static uint8_t single_desc_bytes_hs[] = {</span><br><span>     /* Device descriptors and Configuration descriptors list. */</span><br><span style="color: hsl(0, 100%, 40%);">-    CDCD_ACM_HS_DESCES_HS};</span><br><span style="color: hsl(0, 100%, 40%);">-#define CDCD_ECHO_BUF_SIZ CONF_USB_CDCD_ACM_DATA_BULKIN_MAXPKSZ_HS</span><br><span style="color: hsl(120, 100%, 40%);">+    DFUD_HS_DESCES_HS};</span><br><span> #else</span><br><span> static uint8_t single_desc_bytes[] = {</span><br><span>     /* Device descriptors and Configuration descriptors list. */</span><br><span style="color: hsl(0, 100%, 40%);">-    CDCD_ACM_DESCES_LS_FS};</span><br><span style="color: hsl(0, 100%, 40%);">-#define CDCD_ECHO_BUF_SIZ CONF_USB_CDCD_ACM_DATA_BULKIN_MAXPKSZ</span><br><span style="color: hsl(120, 100%, 40%);">+    DFUD_DESCES_LS_FS};</span><br><span> #endif</span><br><span> </span><br><span> static struct usbd_descriptors single_desc[]</span><br><span>@@ -31,62 +39,19 @@</span><br><span> #endif</span><br><span> };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/** Buffers to receive and echo the communication bytes. */</span><br><span style="color: hsl(0, 100%, 40%);">-static uint32_t usbd_cdc_buffer[CDCD_ECHO_BUF_SIZ / 4];</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /** Ctrl endpoint buffer */</span><br><span> static uint8_t ctrl_buffer[64];</span><br><span> </span><br><span> /**</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief Callback invoked when bulk OUT data received</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief USB DFU Init</span><br><span>  */</span><br><span style="color: hsl(0, 100%, 40%);">-static bool usb_device_cb_bulk_out(const uint8_t ep, const enum usb_xfer_code rc, const uint32_t count)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- cdcdf_acm_write((uint8_t *)usbd_cdc_buffer, count);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     /* No error. */</span><br><span style="color: hsl(0, 100%, 40%);">- return false;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/**</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief Callback invoked when bulk IN data received</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-static bool usb_device_cb_bulk_in(const uint8_t ep, const enum usb_xfer_code rc, const uint32_t count)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-        /* Echo data. */</span><br><span style="color: hsl(0, 100%, 40%);">-        cdcdf_acm_read((uint8_t *)usbd_cdc_buffer, sizeof(usbd_cdc_buffer));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    /* No error. */</span><br><span style="color: hsl(0, 100%, 40%);">- return false;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/**</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief Callback invoked when Line State Change</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-static bool usb_device_cb_state_c(usb_cdc_control_signal_t state)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- if (state.rs232.DTR) {</span><br><span style="color: hsl(0, 100%, 40%);">-          /* Callbacks must be registered after endpoint allocation */</span><br><span style="color: hsl(0, 100%, 40%);">-            cdcdf_acm_register_callback(CDCDF_ACM_CB_READ, (FUNC_PTR)usb_device_cb_bulk_out);</span><br><span style="color: hsl(0, 100%, 40%);">-               cdcdf_acm_register_callback(CDCDF_ACM_CB_WRITE, (FUNC_PTR)usb_device_cb_bulk_in);</span><br><span style="color: hsl(0, 100%, 40%);">-               /* Start Rx */</span><br><span style="color: hsl(0, 100%, 40%);">-          cdcdf_acm_read((uint8_t *)usbd_cdc_buffer, sizeof(usbd_cdc_buffer));</span><br><span style="color: hsl(0, 100%, 40%);">-    }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* No error. */</span><br><span style="color: hsl(0, 100%, 40%);">- return false;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/**</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief CDC ACM Init</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-void cdc_device_acm_init(void)</span><br><span style="color: hsl(120, 100%, 40%);">+void usb_dfu_init(void)</span><br><span> {</span><br><span>       /* usb stack init */</span><br><span>         usbdc_init(ctrl_buffer);</span><br><span> </span><br><span>         /* usbdc_register_funcion inside */</span><br><span style="color: hsl(0, 100%, 40%);">-     cdcdf_acm_init();</span><br><span style="color: hsl(120, 100%, 40%);">+     dfudf_init();</span><br><span> </span><br><span>    usbdc_start(single_desc);</span><br><span>    usbdc_attach();</span><br><span>@@ -102,14 +67,12 @@</span><br><span>  * - Open a HyperTerminal or other COM tools in PC side.</span><br><span>  * - Send out a character or string and it will echo the content received.</span><br><span>  */</span><br><span style="color: hsl(0, 100%, 40%);">-void cdcd_acm_example(void)</span><br><span style="color: hsl(120, 100%, 40%);">+void usb_dfu(void)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-     while (!cdcdf_acm_is_enabled()) {</span><br><span style="color: hsl(0, 100%, 40%);">-               // wait cdc acm to be installed</span><br><span style="color: hsl(120, 100%, 40%);">+       while (!dfudf_is_enabled()) {</span><br><span style="color: hsl(120, 100%, 40%);">+         // wait DFU to be installed</span><br><span>  };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  cdcdf_acm_register_callback(CDCDF_ACM_CB_STATE_C, (FUNC_PTR)usb_device_cb_state_c);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>  while (1) {</span><br><span>  }</span><br><span> }</span><br><span>@@ -117,5 +80,5 @@</span><br><span> void usb_init(void)</span><br><span> {</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-     cdc_device_acm_init();</span><br><span style="color: hsl(120, 100%, 40%);">+        usb_dfu_init();</span><br><span> }</span><br><span>diff --git a/usb_start.h b/usb_start.h</span><br><span>index 48b2735..37502b4 100644</span><br><span>--- a/usb_start.h</span><br><span>+++ b/usb_start.h</span><br><span>@@ -1,9 +1,19 @@</span><br><span> /*</span><br><span style="color: hsl(0, 100%, 40%);">- * Code generated from Atmel Start.</span><br><span style="color: hsl(120, 100%, 40%);">+ * (C) 2018, sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de></span><br><span>  *</span><br><span style="color: hsl(0, 100%, 40%);">- * This file will be overwritten when reconfiguring your Atmel Start project.</span><br><span style="color: hsl(0, 100%, 40%);">- * Please copy examples or other code you want to keep to a separate file or main.c</span><br><span style="color: hsl(0, 100%, 40%);">- * to avoid loosing it when reconfiguring.</span><br><span style="color: hsl(120, 100%, 40%);">+ * This library is free software; you can redistribute it and/or</span><br><span style="color: hsl(120, 100%, 40%);">+ * modify it under the terms of the GNU Lesser General Public</span><br><span style="color: hsl(120, 100%, 40%);">+ * License as published by the Free Software Foundation; either</span><br><span style="color: hsl(120, 100%, 40%);">+ * version 2.1 of the License, or (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This library is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span><br><span style="color: hsl(120, 100%, 40%);">+ * Lesser General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU Lesser General Public</span><br><span style="color: hsl(120, 100%, 40%);">+ * License along with this library; if not, write to the Free Software</span><br><span style="color: hsl(120, 100%, 40%);">+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA</span><br><span>  */</span><br><span> #ifndef USB_DEVICE_MAIN_H</span><br><span> #define USB_DEVICE_MAIN_H</span><br><span>@@ -12,11 +22,11 @@</span><br><span> extern "C" {</span><br><span> #endif // __cplusplus</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#include "cdcdf_acm.h"</span><br><span style="color: hsl(0, 100%, 40%);">-#include "cdcdf_acm_desc.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "dfudf.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "dfudf_desc.h"</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-void cdcd_acm_example(void);</span><br><span style="color: hsl(0, 100%, 40%);">-void cdc_device_acm_init(void);</span><br><span style="color: hsl(120, 100%, 40%);">+void usb_dfu(void);</span><br><span style="color: hsl(120, 100%, 40%);">+void usb_dfu_init(void);</span><br><span> </span><br><span> /**</span><br><span>  * \berif Initialize USB</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12496">change 12496</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12496"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-asf4-dfu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I7bd6cb46b734ffe8a51f2de7083b4f9e76d385e6 </div>
<div style="display:none"> Gerrit-Change-Number: 12496 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Kévin Redon <kredon@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Kévin Redon <kredon@sysmocom.de> </div>