]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC/ThirdParty/LPCOpen/LPCUSBLib/Drivers/USB/Core/DCD/USBRom/usbd_dfu.h
Update LPC18xx FreeRTOS+UDP demo to use LPCOpen USB and Ethernet drivers.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC / ThirdParty / LPCOpen / LPCUSBLib / Drivers / USB / Core / DCD / USBRom / usbd_dfu.h
1 /*\r
2  * @brief Definition of DFU class descriptors and their bit defines\r
3  *\r
4  * @note\r
5  * Copyright(C) NXP Semiconductors, 2012\r
6   * All rights reserved.\r
7  *\r
8  * @par\r
9  * Software that is described herein is for illustrative purposes only\r
10  * which provides customers with programming information regarding the\r
11  * LPC products.  This software is supplied "AS IS" without any warranties of\r
12  * any kind, and NXP Semiconductors and its licensor disclaim any and\r
13  * all warranties, express or implied, including all implied warranties of\r
14  * merchantability, fitness for a particular purpose and non-infringement of\r
15  * intellectual property rights.  NXP Semiconductors assumes no responsibility\r
16  * or liability for the use of the software, conveys no license or rights under any\r
17  * patent, copyright, mask work right, or any other intellectual property rights in\r
18  * or to any products. NXP Semiconductors reserves the right to make changes\r
19  * in the software without notification. NXP Semiconductors also makes no\r
20  * representation or warranty that such application will be suitable for the\r
21  * specified use without further testing or modification.\r
22  *\r
23  * @par\r
24  * Permission to use, copy, modify, and distribute this software and its\r
25  * documentation is hereby granted, under NXP Semiconductors' and its\r
26  * licensor's relevant copyrights in the software, without fee, provided that it\r
27  * is used in conjunction with NXP Semiconductors microcontrollers.  This\r
28  * copyright, permission, and disclaimer notice must appear in all copies of\r
29  * this code.\r
30  */\r
31 \r
32 #include "usbd.h"\r
33 \r
34 #ifndef __MW_USBD_DFU_H__\r
35 #define __MW_USBD_DFU_H__\r
36 \r
37 \r
38 /**\r
39  * If USB device is only DFU capable, DFU Interface number is always 0.\r
40  * if USB device is (DFU + Other Class (Audio/Mass Storage/HID), DFU\r
41  * Interface number should also be 0 in this implementation.\r
42  */\r
43 #define USB_DFU_IF_NUM  0x0\r
44 \r
45 #define USB_DFU_DESCRIPTOR_TYPE     0x21\r
46 #define USB_DFU_DESCRIPTOR_SIZE     9\r
47 #define USB_DFU_SUBCLASS            0x01\r
48 #define USB_DFU_XFER_SIZE           2048\r
49 \r
50 /* DFU class-specific requests (Section 3, DFU Rev 1.1) */\r
51 #define USB_REQ_DFU_DETACH          0x00\r
52 #define USB_REQ_DFU_DNLOAD          0x01\r
53 #define USB_REQ_DFU_UPLOAD          0x02\r
54 #define USB_REQ_DFU_GETSTATUS       0x03\r
55 #define USB_REQ_DFU_CLRSTATUS       0x04\r
56 #define USB_REQ_DFU_GETSTATE        0x05\r
57 #define USB_REQ_DFU_ABORT           0x06\r
58 \r
59 #define DFU_STATUS_OK               0x00\r
60 #define DFU_STATUS_errTARGET        0x01\r
61 #define DFU_STATUS_errFILE          0x02\r
62 #define DFU_STATUS_errWRITE         0x03\r
63 #define DFU_STATUS_errERASE         0x04\r
64 #define DFU_STATUS_errCHECK_ERASED  0x05\r
65 #define DFU_STATUS_errPROG          0x06\r
66 #define DFU_STATUS_errVERIFY        0x07\r
67 #define DFU_STATUS_errADDRESS       0x08\r
68 #define DFU_STATUS_errNOTDONE       0x09\r
69 #define DFU_STATUS_errFIRMWARE      0x0a\r
70 #define DFU_STATUS_errVENDOR        0x0b\r
71 #define DFU_STATUS_errUSBR          0x0c\r
72 #define DFU_STATUS_errPOR           0x0d\r
73 #define DFU_STATUS_errUNKNOWN       0x0e\r
74 #define DFU_STATUS_errSTALLEDPKT    0x0f\r
75 \r
76 enum dfu_state {\r
77   DFU_STATE_appIDLE             = 0,\r
78   DFU_STATE_appDETACH           = 1,\r
79   DFU_STATE_dfuIDLE             = 2,\r
80   DFU_STATE_dfuDNLOAD_SYNC      = 3,\r
81   DFU_STATE_dfuDNBUSY           = 4,\r
82   DFU_STATE_dfuDNLOAD_IDLE      = 5,\r
83   DFU_STATE_dfuMANIFEST_SYNC    = 6,\r
84   DFU_STATE_dfuMANIFEST         = 7,\r
85   DFU_STATE_dfuMANIFEST_WAIT_RST= 8,\r
86   DFU_STATE_dfuUPLOAD_IDLE      = 9,\r
87   DFU_STATE_dfuERROR            = 10\r
88 };\r
89 \r
90 #define DFU_EP0_NONE            0\r
91 #define DFU_EP0_UNHANDLED       1\r
92 #define DFU_EP0_STALL           2\r
93 #define DFU_EP0_ZLP             3\r
94 #define DFU_EP0_DATA            4\r
95 \r
96 #define USB_DFU_CAN_DOWNLOAD    (1 << 0)\r
97 #define USB_DFU_CAN_UPLOAD      (1 << 1)\r
98 #define USB_DFU_MANIFEST_TOL    (1 << 2)\r
99 #define USB_DFU_WILL_DETACH     (1 << 3)\r
100 \r
101 PRE_PACK struct POST_PACK _USB_DFU_FUNC_DESCRIPTOR {\r
102   uint8_t   bLength;\r
103   uint8_t   bDescriptorType;\r
104   uint8_t   bmAttributes;\r
105   uint16_t  wDetachTimeOut;\r
106   uint16_t  wTransferSize;\r
107   uint16_t  bcdDFUVersion;\r
108 };\r
109 typedef struct _USB_DFU_FUNC_DESCRIPTOR USB_DFU_FUNC_DESCRIPTOR;\r
110 \r
111 PRE_PACK struct POST_PACK _DFU_STATUS {\r
112   uint8_t bStatus;\r
113   uint8_t bwPollTimeout[3];\r
114   uint8_t bState;\r
115   uint8_t iString;\r
116 };\r
117 typedef struct _DFU_STATUS DFU_STATUS_T;\r
118 \r
119 #define DFU_FUNC_DESC_SIZE    sizeof(USB_DFU_FUNC_DESCRIPTOR)\r
120 #define DFU_GET_STATUS_SIZE   0x6\r
121 \r
122 \r
123 #endif  /* __MW_USBD_DFU_H__ */\r