--- /dev/null
+/***********************************************************************\r
+* $Id:: mw_usbd_dfu.h 331 2012-08-09 18:54:34Z usb10131 $\r
+*\r
+* Project: USB device ROM Stack\r
+*\r
+* Description:\r
+* Device Firmware Upgrade (DFU) module.\r
+*\r
+***********************************************************************\r
+* Copyright(C) 2011, NXP Semiconductor\r
+* All rights reserved.\r
+*\r
+* Software that is described herein is for illustrative purposes only\r
+* which provides customers with programming information regarding the\r
+* products. This software is supplied "AS IS" without any warranties.\r
+* NXP Semiconductors assumes no responsibility or liability for the\r
+* use of the software, conveys no license or title under any patent,\r
+* copyright, or mask work right to the product. NXP Semiconductors\r
+* reserves the right to make changes in the software without\r
+* notification. NXP Semiconductors also make no representation or\r
+* warranty that such application will be suitable for the specified\r
+* use without further testing or modification.\r
+**********************************************************************/\r
+#ifndef __MW_USBD_DFU_H__\r
+#define __MW_USBD_DFU_H__\r
+\r
+#include "usbd.h"\r
+\r
+/** \file\r
+ * \brief Device Firmware Upgrade (DFU) class descriptors.\r
+ *\r
+ * Definition of DFU class descriptors and their bit defines.\r
+ *\r
+ */\r
+\r
+/**\r
+ * If USB device is only DFU capable, DFU Interface number is always 0.\r
+ * if USB device is (DFU + Other Class (Audio/Mass Storage/HID), DFU \r
+ * Interface number should also be 0 in this implementation.\r
+ */ \r
+#define USB_DFU_IF_NUM 0x0\r
+\r
+#define USB_DFU_DESCRIPTOR_TYPE 0x21\r
+#define USB_DFU_DESCRIPTOR_SIZE 9\r
+#define USB_DFU_SUBCLASS 0x01\r
+\r
+/* DFU class-specific requests (Section 3, DFU Rev 1.1) */\r
+#define USB_REQ_DFU_DETACH 0x00\r
+#define USB_REQ_DFU_DNLOAD 0x01\r
+#define USB_REQ_DFU_UPLOAD 0x02\r
+#define USB_REQ_DFU_GETSTATUS 0x03\r
+#define USB_REQ_DFU_CLRSTATUS 0x04\r
+#define USB_REQ_DFU_GETSTATE 0x05\r
+#define USB_REQ_DFU_ABORT 0x06\r
+\r
+#define DFU_STATUS_OK 0x00\r
+#define DFU_STATUS_errTARGET 0x01\r
+#define DFU_STATUS_errFILE 0x02\r
+#define DFU_STATUS_errWRITE 0x03\r
+#define DFU_STATUS_errERASE 0x04\r
+#define DFU_STATUS_errCHECK_ERASED 0x05\r
+#define DFU_STATUS_errPROG 0x06\r
+#define DFU_STATUS_errVERIFY 0x07\r
+#define DFU_STATUS_errADDRESS 0x08\r
+#define DFU_STATUS_errNOTDONE 0x09\r
+#define DFU_STATUS_errFIRMWARE 0x0a\r
+#define DFU_STATUS_errVENDOR 0x0b\r
+#define DFU_STATUS_errUSBR 0x0c\r
+#define DFU_STATUS_errPOR 0x0d\r
+#define DFU_STATUS_errUNKNOWN 0x0e\r
+#define DFU_STATUS_errSTALLEDPKT 0x0f\r
+\r
+enum dfu_state {\r
+ DFU_STATE_appIDLE = 0,\r
+ DFU_STATE_appDETACH = 1,\r
+ DFU_STATE_dfuIDLE = 2,\r
+ DFU_STATE_dfuDNLOAD_SYNC = 3,\r
+ DFU_STATE_dfuDNBUSY = 4,\r
+ DFU_STATE_dfuDNLOAD_IDLE = 5,\r
+ DFU_STATE_dfuMANIFEST_SYNC = 6,\r
+ DFU_STATE_dfuMANIFEST = 7,\r
+ DFU_STATE_dfuMANIFEST_WAIT_RST= 8,\r
+ DFU_STATE_dfuUPLOAD_IDLE = 9,\r
+ DFU_STATE_dfuERROR = 10\r
+};\r
+\r
+#define DFU_EP0_NONE 0\r
+#define DFU_EP0_UNHANDLED 1\r
+#define DFU_EP0_STALL 2\r
+#define DFU_EP0_ZLP 3\r
+#define DFU_EP0_DATA 4\r
+\r
+#define USB_DFU_CAN_DOWNLOAD (1 << 0)\r
+#define USB_DFU_CAN_UPLOAD (1 << 1)\r
+#define USB_DFU_MANIFEST_TOL (1 << 2)\r
+#define USB_DFU_WILL_DETACH (1 << 3)\r
+\r
+PRE_PACK struct POST_PACK _USB_DFU_FUNC_DESCRIPTOR {\r
+ uint8_t bLength;\r
+ uint8_t bDescriptorType;\r
+ uint8_t bmAttributes;\r
+ uint16_t wDetachTimeOut;\r
+ uint16_t wTransferSize;\r
+ uint16_t bcdDFUVersion;\r
+};\r
+typedef struct _USB_DFU_FUNC_DESCRIPTOR USB_DFU_FUNC_DESCRIPTOR;\r
+\r
+PRE_PACK struct POST_PACK _DFU_STATUS {\r
+ uint8_t bStatus;\r
+ uint8_t bwPollTimeout[3];\r
+ uint8_t bState;\r
+ uint8_t iString;\r
+};\r
+typedef struct _DFU_STATUS DFU_STATUS_T;\r
+\r
+#define DFU_FUNC_DESC_SIZE sizeof(USB_DFU_FUNC_DESCRIPTOR)\r
+#define DFU_GET_STATUS_SIZE 0x6 \r
+\r
+\r
+#endif /* __MW_USBD_DFU_H__ */\r