Lightweight USB stack  1.0
usb_dfu.h
1 /* This file is the part of the Lightweight USB device Stack for STM32 microcontrollers
2  *
3  * Copyright ©2016 Dmitry Filimonchuk <dmitrystu[at]gmail[dot]com>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef _USB_DFU_H_
17 #define _USB_DFU_H_
18 
19 #if defined(__cplusplus)
20  extern "C" {
21 #endif
22 
32 #define USB_CLASS_DFU 0xFE
33 #define USB_DFU_SUBCLASS_DFU 0x01
34 #define USB_DFU_PROTO_RUNTIME 0x01
35 #define USB_DFU_PROTO_DFU 0x02
39 #define USB_DTYPE_DFU_FUNCTIONAL 0x21
43 #define USB_DFU_DETACH 0x00
45 #define USB_DFU_DNLOAD 0x01
46 #define USB_DFU_UPLOAD 0x02
48 #define USB_DFU_GETSTATUS 0x03
50 #define USB_DFU_CLRSTATUS 0x04
52 #define USB_DFU_GETSTATE 0x05
54 #define USB_DFU_ABORT 0x06
61 #define USB_DFU_ATTR_WILL_DETACH 0x08
63 #define USB_DFU_ATTR_MANIF_TOL 0x04
65 #define USB_DFU_ATTR_CAN_UPLOAD 0x02
66 #define USB_DFU_ATTR_CAN_DNLOAD 0x01
71 #define USB_DFU_STATUS_OK 0x00
72 #define USB_DFU_STATUS_ERR_TARGET 0x01
73 #define USB_DFU_STATUS_ERR_FILE 0x02
75 #define USB_DFU_STATUS_ERR_WRITE 0x03
76 #define USB_DFU_STATUS_ERR_ERASE 0x04
77 #define USB_DFU_STATUS_ERR_CHECK_ERASED 0x05
78 #define USB_DFU_STATUS_ERR_PROG 0x06
79 #define USB_DFU_STATUS_ERR_VERIFY 0x07
80 #define USB_DFU_STATUS_ERR_ADDRESS 0x08
82 #define USB_DFU_STATUS_ERR_NOTDONE 0x09
84 #define USB_DFU_STATUS_ERR_FIRMWARE 0x0A
86 #define USB_DFU_STATUS_ERR_VENDOR 0x0B
87 #define USB_DFU_STATUS_ERR_USBR 0x0C
88 #define USB_DFU_STATUS_ERR_POR 0x0D
89 #define USB_DFU_STATUS_ERR_UNKNOWN 0x0E
91 #define USB_DFU_STATUS_ERR_STALLEDPKT 0x0F
96 #define USB_DFU_STATE_APP_IDLE 0x00
97 #define USB_DFU_STATE_APP_DETACH 0x01
100 #define USB_DFU_STATE_DFU_IDLE 0x02
102 #define USB_DFU_STATE_DFU_DNLOADSYNC 0x03
104 #define USB_DFU_STATE_DFU_DNBUSY 0x04
106 #define USB_DFU_STATE_DFU_DNLOADIDLE 0x05
108 #define USB_DFU_STATE_DFU_MANIFESTSYNC 0x06
116 #define USB_DFU_STATE_DFU_MANIFEST 0x07
119 #define USB_DFU_STATE_DFU_MANIFESTWR 0x08
123 #define USB_DFU_STATE_DFU_UPLOADIDLE 0x09
124 #define USB_DFU_STATE_DFU_ERROR 0x0A
128 struct usb_dfu_func_desc {
129  uint8_t bLength;
130  uint8_t bDescriptorType;
131  uint8_t bmAttributes;
132  uint16_t wDetachTimeout;
133  uint16_t wTransferSize;
134  uint16_t bcdDFUVersion;
135 }__attribute__((packed));
136 
138 struct usb_dfu_status {
139  uint8_t bStatus;
141  uint8_t bPollTimeout;
143  uint16_t wPollTimeout;
145  uint8_t bState;
147  uint8_t iString;
148 };
149 
152 #if defined(__cplusplus)
153  }
154 #endif
155 #endif /* _USB_DFU_H_ */
uint8_t bStatus
An indication of the status resulting from the execution of the most recent request.
Definition: usb_dfu.h:170
uint8_t iString
Index of the status string descriptor.
Definition: usb_dfu.h:178
uint16_t wPollTimeout
Minimum time (MSB) in ms, that the host should wait before sending a subsequent DFU_GETSTATUS request...
Definition: usb_dfu.h:174
uint8_t bState
An indication of the state that the device is going to enter immediately following transmission of th...
Definition: usb_dfu.h:176
uint8_t bPollTimeout
Minimum time (LSB) in ms, that the host should wait before sending a subsequent DFU_GETSTATUS request...
Definition: usb_dfu.h:172
Payload packet to response in DFU_GETSTATUS request.
Definition: usb_dfu.h:169