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