Merge pull request #93 from zyp/master
[fw/stlink] / example / stm32f4 / STM32_USB_Device_Library / Core / inc / usbd_def.h
1 /**
2   ******************************************************************************
3   * @file    usbd_def.h
4   * @author  MCD Application Team
5   * @version V1.0.0
6   * @date    22-July-2011
7   * @brief   general defines for the usb device library 
8   ******************************************************************************
9   * @attention 
10   *
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. 
17   *
18   * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
19   ******************************************************************************
20   */ 
21
22 /* Define to prevent recursive inclusion -------------------------------------*/
23
24 #ifndef __USBD_DEF_H
25 #define __USBD_DEF_H
26 /* Includes ------------------------------------------------------------------*/
27 #include "usbd_conf.h"
28
29 /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
30   * @{
31   */
32   
33 /** @defgroup USB_DEF
34   * @brief general defines for the usb device library file
35   * @{
36   */ 
37
38 /** @defgroup USB_DEF_Exported_Defines
39   * @{
40   */ 
41
42 #ifndef NULL
43 #define NULL    0
44 #endif
45
46 #define  USB_LEN_DEV_QUALIFIER_DESC                     0x0A
47 #define  USB_LEN_DEV_DESC                               0x12
48 #define  USB_LEN_CFG_DESC                               0x09
49 #define  USB_LEN_IF_DESC                                0x09
50 #define  USB_LEN_EP_DESC                                0x07
51 #define  USB_LEN_OTG_DESC                               0x03
52
53 #define  USBD_IDX_LANGID_STR                            0x00 
54 #define  USBD_IDX_MFC_STR                               0x01 
55 #define  USBD_IDX_PRODUCT_STR                           0x02
56 #define  USBD_IDX_SERIAL_STR                            0x03 
57 #define  USBD_IDX_CONFIG_STR                            0x04 
58 #define  USBD_IDX_INTERFACE_STR                         0x05 
59
60 #define  USB_REQ_TYPE_STANDARD                          0x00
61 #define  USB_REQ_TYPE_CLASS                             0x20
62 #define  USB_REQ_TYPE_VENDOR                            0x40
63 #define  USB_REQ_TYPE_MASK                              0x60
64
65 #define  USB_REQ_RECIPIENT_DEVICE                       0x00
66 #define  USB_REQ_RECIPIENT_INTERFACE                    0x01
67 #define  USB_REQ_RECIPIENT_ENDPOINT                     0x02
68 #define  USB_REQ_RECIPIENT_MASK                         0x03
69
70 #define  USB_REQ_GET_STATUS                             0x00
71 #define  USB_REQ_CLEAR_FEATURE                          0x01
72 #define  USB_REQ_SET_FEATURE                            0x03
73 #define  USB_REQ_SET_ADDRESS                            0x05
74 #define  USB_REQ_GET_DESCRIPTOR                         0x06
75 #define  USB_REQ_SET_DESCRIPTOR                         0x07
76 #define  USB_REQ_GET_CONFIGURATION                      0x08
77 #define  USB_REQ_SET_CONFIGURATION                      0x09
78 #define  USB_REQ_GET_INTERFACE                          0x0A
79 #define  USB_REQ_SET_INTERFACE                          0x0B
80 #define  USB_REQ_SYNCH_FRAME                            0x0C
81
82 #define  USB_DESC_TYPE_DEVICE                              1
83 #define  USB_DESC_TYPE_CONFIGURATION                       2
84 #define  USB_DESC_TYPE_STRING                              3
85 #define  USB_DESC_TYPE_INTERFACE                           4
86 #define  USB_DESC_TYPE_ENDPOINT                            5
87 #define  USB_DESC_TYPE_DEVICE_QUALIFIER                    6
88 #define  USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION           7
89
90
91 #define USB_CONFIG_REMOTE_WAKEUP                           2
92 #define USB_CONFIG_SELF_POWERED                            1
93
94 #define USB_FEATURE_EP_HALT                                0
95 #define USB_FEATURE_REMOTE_WAKEUP                          1
96 #define USB_FEATURE_TEST_MODE                              2
97
98 /**
99   * @}
100   */ 
101
102
103 /** @defgroup USBD_DEF_Exported_TypesDefinitions
104   * @{
105   */
106 /**
107   * @}
108   */ 
109
110
111
112 /** @defgroup USBD_DEF_Exported_Macros
113   * @{
114   */ 
115 #define  SWAPBYTE(addr)        (((uint16_t)(*((uint8_t *)(addr)))) + \
116                                (((uint16_t)(*(((uint8_t *)(addr)) + 1))) << 8))
117
118 #define LOBYTE(x)  ((uint8_t)(x & 0x00FF))
119 #define HIBYTE(x)  ((uint8_t)((x & 0xFF00) >>8))
120 /**
121   * @}
122   */ 
123
124 /** @defgroup USBD_DEF_Exported_Variables
125   * @{
126   */ 
127
128 /**
129   * @}
130   */ 
131
132 /** @defgroup USBD_DEF_Exported_FunctionsPrototype
133   * @{
134   */ 
135
136 /**
137   * @}
138   */ 
139
140 #endif /* __USBD_DEF_H */
141
142 /**
143   * @}
144   */ 
145
146 /**
147 * @}
148 */ 
149 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/