Merge pull request #93 from zyp/master
[fw/stlink] / example / stm32f4 / STM32_USB_OTG_Driver / inc / usb_dcd.h
1 /**
2   ******************************************************************************
3   * @file    usb_dcd.h
4   * @author  MCD Application Team
5   * @version V2.0.0
6   * @date    22-July-2011
7   * @brief   Peripheral Driver Header file
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 #ifndef __DCD_H__
24 #define __DCD_H__
25
26 /* Includes ------------------------------------------------------------------*/
27 #include "usb_core.h"
28
29
30 /** @addtogroup USB_OTG_DRIVER
31 * @{
32 */
33
34 /** @defgroup USB_DCD
35 * @brief This file is the 
36 * @{
37 */ 
38
39
40 /** @defgroup USB_DCD_Exported_Defines
41 * @{
42 */ 
43 #define USB_OTG_EP_CONTROL                       0
44 #define USB_OTG_EP_ISOC                          1
45 #define USB_OTG_EP_BULK                          2
46 #define USB_OTG_EP_INT                           3
47 #define USB_OTG_EP_MASK                          3
48
49 /*  Device Status */
50 #define USB_OTG_DEFAULT                          1
51 #define USB_OTG_ADDRESSED                        2
52 #define USB_OTG_CONFIGURED                       3
53 #define USB_OTG_SUSPENDED                        4
54
55 /**
56 * @}
57 */ 
58
59
60 /** @defgroup USB_DCD_Exported_Types
61 * @{
62 */ 
63 /********************************************************************************
64 Data structure type
65 ********************************************************************************/
66 typedef struct
67 {
68   uint8_t  bLength;
69   uint8_t  bDescriptorType;
70   uint8_t  bEndpointAddress;
71   uint8_t  bmAttributes;
72   uint16_t wMaxPacketSize;
73   uint8_t  bInterval;
74 }
75 EP_DESCRIPTOR , *PEP_DESCRIPTOR;
76
77 /**
78 * @}
79 */ 
80
81
82 /** @defgroup USB_DCD_Exported_Macros
83 * @{
84 */ 
85 /**
86 * @}
87 */ 
88
89 /** @defgroup USB_DCD_Exported_Variables
90 * @{
91 */ 
92 /**
93 * @}
94 */ 
95
96 /** @defgroup USB_DCD_Exported_FunctionsPrototype
97 * @{
98 */ 
99 /********************************************************************************
100 EXPORTED FUNCTION FROM THE USB-OTG LAYER
101 ********************************************************************************/
102 void       DCD_Init(USB_OTG_CORE_HANDLE *pdev ,
103                     USB_OTG_CORE_ID_TypeDef coreID);
104
105 void        DCD_DevConnect (USB_OTG_CORE_HANDLE *pdev);
106 void        DCD_DevDisconnect (USB_OTG_CORE_HANDLE *pdev);
107 void        DCD_EP_SetAddress (USB_OTG_CORE_HANDLE *pdev,
108                                uint8_t address);
109 uint32_t    DCD_EP_Open(USB_OTG_CORE_HANDLE *pdev , 
110                      uint8_t ep_addr,
111                      uint16_t ep_mps,
112                      uint8_t ep_type);
113
114 uint32_t    DCD_EP_Close  (USB_OTG_CORE_HANDLE *pdev,
115                                 uint8_t  ep_addr);
116
117
118 uint32_t   DCD_EP_PrepareRx ( USB_OTG_CORE_HANDLE *pdev,
119                         uint8_t   ep_addr,                                  
120                         uint8_t *pbuf,                                  
121                         uint16_t  buf_len);
122   
123 uint32_t    DCD_EP_Tx (USB_OTG_CORE_HANDLE *pdev,
124                                uint8_t  ep_addr,
125                                uint8_t  *pbuf,
126                                uint32_t   buf_len);
127 uint32_t    DCD_EP_Stall (USB_OTG_CORE_HANDLE *pdev,
128                               uint8_t   epnum);
129 uint32_t    DCD_EP_ClrStall (USB_OTG_CORE_HANDLE *pdev,
130                                   uint8_t epnum);
131 uint32_t    DCD_EP_Flush (USB_OTG_CORE_HANDLE *pdev,
132                                uint8_t epnum);
133 uint32_t    DCD_Handle_ISR(USB_OTG_CORE_HANDLE *pdev);
134
135 uint32_t DCD_GetEPStatus(USB_OTG_CORE_HANDLE *pdev ,
136                          uint8_t epnum);
137
138 void DCD_SetEPStatus (USB_OTG_CORE_HANDLE *pdev , 
139                       uint8_t epnum , 
140                       uint32_t Status);
141
142 /**
143 * @}
144 */ 
145
146
147 #endif //__DCD_H__
148
149
150 /**
151 * @}
152 */ 
153
154 /**
155 * @}
156 */ 
157 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
158