34 #ifndef __MW_USBD_DFU_H__
35 #define __MW_USBD_DFU_H__
43 #define USB_DFU_IF_NUM 0x0
45 #define USB_DFU_DESCRIPTOR_TYPE 0x21
46 #define USB_DFU_DESCRIPTOR_SIZE 9
47 #define USB_DFU_SUBCLASS 0x01
48 #define USB_DFU_XFER_SIZE 2048
51 #define USB_REQ_DFU_DETACH 0x00
52 #define USB_REQ_DFU_DNLOAD 0x01
53 #define USB_REQ_DFU_UPLOAD 0x02
54 #define USB_REQ_DFU_GETSTATUS 0x03
55 #define USB_REQ_DFU_CLRSTATUS 0x04
56 #define USB_REQ_DFU_GETSTATE 0x05
57 #define USB_REQ_DFU_ABORT 0x06
59 #define DFU_STATUS_OK 0x00
60 #define DFU_STATUS_errTARGET 0x01
61 #define DFU_STATUS_errFILE 0x02
62 #define DFU_STATUS_errWRITE 0x03
63 #define DFU_STATUS_errERASE 0x04
64 #define DFU_STATUS_errCHECK_ERASED 0x05
65 #define DFU_STATUS_errPROG 0x06
66 #define DFU_STATUS_errVERIFY 0x07
67 #define DFU_STATUS_errADDRESS 0x08
68 #define DFU_STATUS_errNOTDONE 0x09
69 #define DFU_STATUS_errFIRMWARE 0x0a
70 #define DFU_STATUS_errVENDOR 0x0b
71 #define DFU_STATUS_errUSBR 0x0c
72 #define DFU_STATUS_errPOR 0x0d
73 #define DFU_STATUS_errUNKNOWN 0x0e
74 #define DFU_STATUS_errSTALLEDPKT 0x0f
90 #define DFU_EP0_NONE 0
91 #define DFU_EP0_UNHANDLED 1
92 #define DFU_EP0_STALL 2
94 #define DFU_EP0_DATA 4
96 #define USB_DFU_CAN_DOWNLOAD (1 << 0)
97 #define USB_DFU_CAN_UPLOAD (1 << 1)
98 #define USB_DFU_MANIFEST_TOL (1 << 2)
99 #define USB_DFU_WILL_DETACH (1 << 3)
101 PRE_PACK
struct POST_PACK _USB_DFU_FUNC_DESCRIPTOR {
105 uint16_t wDetachTimeOut;
106 uint16_t wTransferSize;
107 uint16_t bcdDFUVersion;
109 typedef struct _USB_DFU_FUNC_DESCRIPTOR USB_DFU_FUNC_DESCRIPTOR;
111 PRE_PACK
struct POST_PACK _DFU_STATUS {
113 uint8_t bwPollTimeout[3];
117 typedef struct _DFU_STATUS DFU_STATUS_T;
119 #define DFU_FUNC_DESC_SIZE sizeof(USB_DFU_FUNC_DESCRIPTOR)
120 #define DFU_GET_STATUS_SIZE 0x6