]> git.sur5r.net Git - armstart-ibdap/blob - inc/usbd/usbd_dfu.h
Fix build
[armstart-ibdap] / inc / usbd / usbd_dfu.h
1 /***********************************************************************\r
2 * $Id:: mw_usbd_dfu.h 331 2012-08-09 18:54:34Z usb10131                       $\r
3 *\r
4 * Project: USB device ROM Stack\r
5 *\r
6 * Description:\r
7 *     Device Firmware Upgrade (DFU) module.\r
8 *\r
9 ***********************************************************************\r
10 *   Copyright(C) 2011, NXP Semiconductor\r
11 *   All rights reserved.\r
12 *\r
13 * Software that is described herein is for illustrative purposes only\r
14 * which provides customers with programming information regarding the\r
15 * products. This software is supplied "AS IS" without any warranties.\r
16 * NXP Semiconductors assumes no responsibility or liability for the\r
17 * use of the software, conveys no license or title under any patent,\r
18 * copyright, or mask work right to the product. NXP Semiconductors\r
19 * reserves the right to make changes in the software without\r
20 * notification. NXP Semiconductors also make no representation or\r
21 * warranty that such application will be suitable for the specified\r
22 * use without further testing or modification.\r
23 **********************************************************************/\r
24 #ifndef __MW_USBD_DFU_H__\r
25 #define __MW_USBD_DFU_H__\r
26 \r
27 #include "usbd.h"\r
28 \r
29 /** \file\r
30  *  \brief Device Firmware Upgrade (DFU) class descriptors.\r
31  *\r
32  *  Definition of DFU class descriptors and their bit defines.\r
33  *\r
34  */\r
35 \r
36 /**\r
37  * If USB device is only DFU capable, DFU Interface number is always 0.\r
38  * if USB device is (DFU + Other Class (Audio/Mass Storage/HID), DFU \r
39  * Interface number should also be 0 in this implementation.\r
40  */ \r
41 #define USB_DFU_IF_NUM  0x0\r
42 \r
43 #define USB_DFU_DESCRIPTOR_TYPE     0x21\r
44 #define USB_DFU_DESCRIPTOR_SIZE     9\r
45 #define USB_DFU_SUBCLASS            0x01\r
46 \r
47 /* DFU class-specific requests (Section 3, DFU Rev 1.1) */\r
48 #define USB_REQ_DFU_DETACH          0x00\r
49 #define USB_REQ_DFU_DNLOAD          0x01\r
50 #define USB_REQ_DFU_UPLOAD          0x02\r
51 #define USB_REQ_DFU_GETSTATUS       0x03\r
52 #define USB_REQ_DFU_CLRSTATUS       0x04\r
53 #define USB_REQ_DFU_GETSTATE        0x05\r
54 #define USB_REQ_DFU_ABORT           0x06\r
55 \r
56 #define DFU_STATUS_OK               0x00\r
57 #define DFU_STATUS_errTARGET        0x01\r
58 #define DFU_STATUS_errFILE          0x02\r
59 #define DFU_STATUS_errWRITE         0x03\r
60 #define DFU_STATUS_errERASE         0x04\r
61 #define DFU_STATUS_errCHECK_ERASED  0x05\r
62 #define DFU_STATUS_errPROG          0x06\r
63 #define DFU_STATUS_errVERIFY        0x07\r
64 #define DFU_STATUS_errADDRESS       0x08\r
65 #define DFU_STATUS_errNOTDONE       0x09\r
66 #define DFU_STATUS_errFIRMWARE      0x0a\r
67 #define DFU_STATUS_errVENDOR        0x0b\r
68 #define DFU_STATUS_errUSBR          0x0c\r
69 #define DFU_STATUS_errPOR           0x0d\r
70 #define DFU_STATUS_errUNKNOWN       0x0e\r
71 #define DFU_STATUS_errSTALLEDPKT    0x0f\r
72 \r
73 enum dfu_state {\r
74   DFU_STATE_appIDLE             = 0,\r
75   DFU_STATE_appDETACH           = 1,\r
76   DFU_STATE_dfuIDLE             = 2,\r
77   DFU_STATE_dfuDNLOAD_SYNC      = 3,\r
78   DFU_STATE_dfuDNBUSY           = 4,\r
79   DFU_STATE_dfuDNLOAD_IDLE      = 5,\r
80   DFU_STATE_dfuMANIFEST_SYNC    = 6,\r
81   DFU_STATE_dfuMANIFEST         = 7,\r
82   DFU_STATE_dfuMANIFEST_WAIT_RST= 8,\r
83   DFU_STATE_dfuUPLOAD_IDLE      = 9,\r
84   DFU_STATE_dfuERROR            = 10\r
85 };\r
86 \r
87 #define DFU_EP0_NONE            0\r
88 #define DFU_EP0_UNHANDLED       1\r
89 #define DFU_EP0_STALL           2\r
90 #define DFU_EP0_ZLP             3\r
91 #define DFU_EP0_DATA            4\r
92 \r
93 #define USB_DFU_CAN_DOWNLOAD    (1 << 0)\r
94 #define USB_DFU_CAN_UPLOAD      (1 << 1)\r
95 #define USB_DFU_MANIFEST_TOL    (1 << 2)\r
96 #define USB_DFU_WILL_DETACH     (1 << 3)\r
97 \r
98 PRE_PACK struct POST_PACK _USB_DFU_FUNC_DESCRIPTOR {\r
99   uint8_t   bLength;\r
100   uint8_t   bDescriptorType;\r
101   uint8_t   bmAttributes;\r
102   uint16_t  wDetachTimeOut;\r
103   uint16_t  wTransferSize;\r
104   uint16_t  bcdDFUVersion;\r
105 };\r
106 typedef struct _USB_DFU_FUNC_DESCRIPTOR USB_DFU_FUNC_DESCRIPTOR;\r
107 \r
108 PRE_PACK struct POST_PACK _DFU_STATUS {\r
109   uint8_t bStatus;\r
110   uint8_t bwPollTimeout[3];\r
111   uint8_t bState;\r
112   uint8_t iString;\r
113 };\r
114 typedef struct _DFU_STATUS DFU_STATUS_T;\r
115 \r
116 #define DFU_FUNC_DESC_SIZE    sizeof(USB_DFU_FUNC_DESCRIPTOR)\r
117 #define DFU_GET_STATUS_SIZE   0x6 \r
118 \r
119 \r
120 #endif  /* __MW_USBD_DFU_H__ */\r