GD32F10x USB-Device: E:/USB Libraries/GD32_USB_Device_Library/Class/dfu/inc/usbd_dfu_core.h Source File

GD32F103 Firmware

usbd_dfu_core.h
Go to the documentation of this file.
1 
11 /* Define to prevent recursive inclusion -------------------------------------*/
12 #ifndef __GD32F10X_USBD_DFU_CORE_H
13 #define __GD32F10X_USBD_DFU_CORE_H
14 
15 /* Includes ------------------------------------------------------------------*/
16 #include "usbd_dfu_mal.h"
17 #include "usbd_enum.h"
18 
38 #define USB_DFU_CONFIG_DESC_SIZE (18 + (9 * USBD_ITF_MAX_NUM))
39 #define USB_DFU_DESC_SIZE 9
40 #define DFU_DESC_TYPE 0x21
41 
42 /* Manifestation State */
43 #define Manifest_complete 0x00
44 #define Manifest_In_Progress 0x01
45 
46 /* Special commands with download request */
47 #define GET_COMMANDS 0x00
48 #define SET_ADDRESS_POINTER 0x21
49 #define ERASE 0x41
50 
51 /* Memory operation command */
52 #define CMD_ERASE 0
53 #define CMD_WRITE 1
54 
55 /* Bit detach capable = bit 3 in bmAttributes field */
56 #define DFU_DETACH_MASK (uint8_t)(0x10)
57 
66 /* DFU device state defines */
67 typedef enum _DFU_STATE
68 {
69  STATE_appIDLE = 0x00,
70  STATE_appDETACH,
71  STATE_dfuIDLE,
72  STATE_dfuDNLOAD_SYNC ,
73  STATE_dfuDNBUSY,
74  STATE_dfuDNLOAD_IDLE,
75  STATE_dfuMANIFEST_SYNC,
76  STATE_dfuMANIFEST,
77  STATE_dfuMANIFEST_WAIT_RESET,
78  STATE_dfuUPLOAD_IDLE,
79  STATE_dfuERROR
80 }
81 DFU_STATE;
82 
83 /* DFU device status defines */
84 typedef enum _DFU_STATUS
85 {
86  STATUS_OK = 0x00,
87  STATUS_errTARGET,
88  STATUS_errFILE,
89  STATUS_errWRITE,
90  STATUS_errERASE,
91  STATUS_errCHECK_ERASED,
92  STATUS_errPROG,
93  STATUS_errVERIFY,
94  STATUS_errADDRESS,
95  STATUS_errNOTDONE,
96  STATUS_errFIRMWARE,
97  STATUS_errVENDOR,
98  STATUS_errUSBR,
99  STATUS_errPOR,
100  STATUS_errUNKNOWN,
101  STATUS_errSTALLEDPKT
102 }
103 DFU_STATUS;
104 
105 /* DFU class-specific requests */
106 typedef enum _DFU_REQUESTS
107 {
108  DFU_DETACH = 0,
109  DFU_DNLOAD,
110  DFU_UPLOAD,
111  DFU_GETSTATUS,
112  DFU_CLRSTATUS,
113  DFU_GETSTATE,
114  DFU_ABORT
115 }
116 DFU_REQUESTS;
117 
118 typedef void (*pAppFunction) (void);
119 
128 /********** Descriptor of DFU interface 0 Alternate setting n ****************/
129 #define USBD_DFU_IF_DESC(n) 0x09, /* bLength: interface descriptor size */ \
130  USB_DESCTYPE_INTERFACE, /* bDescriptorType */ \
131  0x00, /* bInterfaceNumber: number of interface */ \
132  (n), /* bAlternateSetting: alternate setting */ \
133  0x00, /* bNumEndpoints: no use non control endpoint */ \
134  0xFE, /* bInterfaceClass: application specific class code */ \
135  0x01, /* bInterfaceSubClass: device firmware upgrade code */ \
136  0x02, /* nInterfaceProtocol: DFU mode protocol */ \
137  USBD_INTERFACE_STR_IDX + (n) + 1 /* iInterface: index of string descriptor */
138 
146 extern USBD_Class_cb_TypeDef USBD_DFU_cb;
147 
152 #endif /* __GD32F10X_USBD_DFU_CORE_H */
153 
170 /************************ (C) COPYRIGHT 2014 GIGADEVICE *****END OF FILE****/
USB device class callback type define.
Definition: usb_core.h:148
USB DFU device media access layer header file.
USB enumeration function prototypes.
Generated on Fri Feb 6 2015 14:56:35 for GD32F10x USB-Device by   doxygen 1.8.8