2 ******************************************************************************
3 * @file usbd_dfu_core.h
4 * @author MCD Application Team
7 * @brief header file for the usbd_dfu_core.c file.
8 ******************************************************************************
11 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
19 ******************************************************************************
22 /* Includes ------------------------------------------------------------------*/
24 #ifndef __USB_DFU_CORE_H_
25 #define __USB_DFU_CORE_H_
27 #include "usbd_ioreq.h"
28 #include "usbd_dfu_mal.h"
30 /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
34 /** @defgroup usbd_dfu
35 * @brief This file is the Header file for USBD_dfu.c
40 /** @defgroup usbd_dfu_Exported_Defines
43 #define USB_DFU_CONFIG_DESC_SIZ (18 + (9 * USBD_ITF_MAX_NUM))
44 #define USB_DFU_DESC_SIZ 9
46 #define DFU_DESCRIPTOR_TYPE 0x21
49 /*---------------------------------------------------------------------*/
51 /*---------------------------------------------------------------------*/
55 /**************************************************/
56 /* DFU Requests DFU states */
57 /**************************************************/
60 #define STATE_appIDLE 0
61 #define STATE_appDETACH 1
62 #define STATE_dfuIDLE 2
63 #define STATE_dfuDNLOAD_SYNC 3
64 #define STATE_dfuDNBUSY 4
65 #define STATE_dfuDNLOAD_IDLE 5
66 #define STATE_dfuMANIFEST_SYNC 6
67 #define STATE_dfuMANIFEST 7
68 #define STATE_dfuMANIFEST_WAIT_RESET 8
69 #define STATE_dfuUPLOAD_IDLE 9
70 #define STATE_dfuERROR 10
72 /**************************************************/
73 /* DFU Requests DFU status */
74 /**************************************************/
76 #define STATUS_OK 0x00
77 #define STATUS_ERRTARGET 0x01
78 #define STATUS_ERRFILE 0x02
79 #define STATUS_ERRWRITE 0x03
80 #define STATUS_ERRERASE 0x04
81 #define STATUS_ERRCHECK_ERASED 0x05
82 #define STATUS_ERRPROG 0x06
83 #define STATUS_ERRVERIFY 0x07
84 #define STATUS_ERRADDRESS 0x08
85 #define STATUS_ERRNOTDONE 0x09
86 #define STATUS_ERRFIRMWARE 0x0A
87 #define STATUS_ERRVENDOR 0x0B
88 #define STATUS_ERRUSBR 0x0C
89 #define STATUS_ERRPOR 0x0D
90 #define STATUS_ERRUNKNOWN 0x0E
91 #define STATUS_ERRSTALLEDPKT 0x0F
93 /**************************************************/
94 /* DFU Requests DFU states Manifestation State */
95 /**************************************************/
97 #define Manifest_complete 0x00
98 #define Manifest_In_Progress 0x01
101 /**************************************************/
102 /* Special Commands with Download Request */
103 /**************************************************/
105 #define CMD_GETCOMMANDS 0x00
106 #define CMD_SETADDRESSPOINTER 0x21
107 #define CMD_ERASE 0x41
109 /**************************************************/
111 /**************************************************/
112 /* Bit Detach capable = bit 3 in bmAttributes field */
113 #define DFU_DETACH_MASK (uint8_t)(1 << 4)
119 /** @defgroup USBD_CORE_Exported_TypesDefinitions
122 /**************************************************/
124 /**************************************************/
126 typedef enum _DFU_REQUESTS {
136 typedef void (*pFunction)(void);
143 /** @defgroup USBD_CORE_Exported_Macros
146 /********** Descriptor of DFU interface 0 Alternate setting n ****************/
147 #define USBD_DFU_IF_DESC(n) 0x09, /* bLength: Interface Descriptor size */ \
148 USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ \
149 0x00, /* bInterfaceNumber: Number of Interface */ \
150 (n), /* bAlternateSetting: Alternate setting */ \
151 0x00, /* bNumEndpoints*/ \
152 0xFE, /* bInterfaceClass: Application Specific Class Code */ \
153 0x01, /* bInterfaceSubClass : Device Firmware Upgrade Code */ \
154 0x02, /* nInterfaceProtocol: DFU mode protocol */ \
155 USBD_IDX_INTERFACE_STR + (n) + 1 /* iInterface: Index of string descriptor */ \
162 /** @defgroup USBD_CORE_Exported_Variables
166 extern USBD_Class_cb_TypeDef DFU_cb;
171 /** @defgroup USB_CORE_Exported_Functions
178 #endif // __USB_DFU_CORE_H_
187 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/