Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 3 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /** |
1 | /** |
2 | ****************************************************************************** |
2 | ****************************************************************************** |
3 | * @file stm32f1xx_ll_usb.h |
3 | * @file stm32f1xx_ll_usb.h |
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @brief Header file of USB Low Layer HAL module. |
5 | * @brief Header file of USB Low Layer HAL module. |
6 | ****************************************************************************** |
6 | ****************************************************************************** |
7 | * @attention |
7 | * @attention |
8 | * |
8 | * |
9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
9 | * Copyright (c) 2016 STMicroelectronics. |
10 | * All rights reserved.</center></h2> |
10 | * All rights reserved. |
11 | * |
11 | * |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
12 | * This software is licensed under terms that can be found in the LICENSE file |
13 | * the "License"; You may not use this file except in compliance with the |
13 | * in the root directory of this software component. |
14 | * License. You may obtain a copy of the License at: |
14 | * If no LICENSE file comes with this software, it is provided AS-IS. |
15 | * opensource.org/licenses/BSD-3-Clause |
15 | * |
16 | * |
16 | ****************************************************************************** |
17 | ****************************************************************************** |
17 | */ |
18 | */ |
18 | |
19 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ |
|
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | #ifndef STM32F1xx_LL_USB_H |
21 | #ifndef STM32F1xx_LL_USB_H |
21 | #define STM32F1xx_LL_USB_H |
22 | #define STM32F1xx_LL_USB_H |
22 | |
23 | 23 | #ifdef __cplusplus |
|
24 | #ifdef __cplusplus |
24 | extern "C" { |
25 | extern "C" { |
25 | #endif /* __cplusplus */ |
26 | #endif |
26 | |
27 | 27 | /* Includes ------------------------------------------------------------------*/ |
|
28 | /* Includes ------------------------------------------------------------------*/ |
28 | #include "stm32f1xx_hal_def.h" |
29 | #include "stm32f1xx_hal_def.h" |
29 | |
30 | 30 | #if defined (USB) || defined (USB_OTG_FS) |
|
31 | #if defined (USB) || defined (USB_OTG_FS) |
31 | /** @addtogroup STM32F1xx_HAL_Driver |
32 | /** @addtogroup STM32F1xx_HAL_Driver |
32 | * @{ |
33 | * @{ |
33 | */ |
34 | */ |
34 | |
35 | 35 | /** @addtogroup USB_LL |
|
36 | /** @addtogroup USB_LL |
36 | * @{ |
37 | * @{ |
37 | */ |
38 | */ |
38 | |
39 | 39 | /* Exported types ------------------------------------------------------------*/ |
|
40 | /* Exported types ------------------------------------------------------------*/ |
40 | |
41 | 41 | /** |
|
42 | /** |
42 | * @brief USB Mode definition |
43 | * @brief USB Mode definition |
43 | */ |
44 | */ |
44 | |
45 | #if defined (USB_OTG_FS) |
45 | typedef enum |
46 | 46 | { |
|
47 | typedef enum |
47 | USB_DEVICE_MODE = 0, |
48 | { |
48 | USB_HOST_MODE = 1, |
49 | USB_DEVICE_MODE = 0, |
49 | USB_DRD_MODE = 2 |
50 | USB_HOST_MODE = 1, |
50 | } USB_ModeTypeDef; |
51 | USB_DRD_MODE = 2 |
51 | |
52 | } USB_ModeTypeDef; |
52 | /** |
53 | 53 | * @brief URB States definition |
|
54 | /** |
54 | */ |
55 | * @brief URB States definition |
55 | typedef enum |
56 | */ |
56 | { |
57 | typedef enum |
57 | URB_IDLE = 0, |
58 | { |
58 | URB_DONE, |
59 | URB_IDLE = 0, |
59 | URB_NOTREADY, |
60 | URB_DONE, |
60 | URB_NYET, |
61 | URB_NOTREADY, |
61 | URB_ERROR, |
62 | URB_NYET, |
62 | URB_STALL |
63 | URB_ERROR, |
63 | } USB_URBStateTypeDef; |
64 | URB_STALL |
64 | |
65 | } USB_OTG_URBStateTypeDef; |
65 | /** |
66 | 66 | * @brief Host channel States definition |
|
67 | /** |
67 | */ |
68 | * @brief Host channel States definition |
68 | typedef enum |
69 | */ |
69 | { |
70 | typedef enum |
70 | HC_IDLE = 0, |
71 | { |
71 | HC_XFRC, |
72 | HC_IDLE = 0, |
72 | HC_HALTED, |
73 | HC_XFRC, |
73 | HC_ACK, |
74 | HC_HALTED, |
74 | HC_NAK, |
75 | HC_NAK, |
75 | HC_NYET, |
76 | HC_NYET, |
76 | HC_STALL, |
77 | HC_STALL, |
77 | HC_XACTERR, |
78 | HC_XACTERR, |
78 | HC_BBLERR, |
79 | HC_BBLERR, |
79 | HC_DATATGLERR |
80 | HC_DATATGLERR |
80 | } USB_HCStateTypeDef; |
81 | } USB_OTG_HCStateTypeDef; |
81 | |
82 | 82 | ||
83 | /** |
83 | /** |
84 | * @brief USB Instance Initialization Structure definition |
84 | * @brief USB Instance Initialization Structure definition |
85 | */ |
85 | */ |
86 | typedef struct |
86 | typedef struct |
87 | { |
87 | { |
88 | uint32_t dev_endpoints; /*!< Device Endpoints number. |
88 | uint32_t dev_endpoints; /*!< Device Endpoints number. |
89 | This parameter depends on the used USB core. |
89 | This parameter depends on the used USB core. |
90 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
90 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
91 | 91 | ||
92 | uint32_t Host_channels; /*!< Host Channels number. |
92 | #if defined (USB_OTG_FS) |
93 | This parameter Depends on the used USB core. |
93 | uint32_t Host_channels; /*!< Host Channels number. |
94 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
94 | This parameter Depends on the used USB core. |
95 | 95 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
|
96 | uint32_t speed; /*!< USB Core speed. |
96 | |
97 | This parameter can be any value of @ref PCD_Speed/HCD_Speed |
97 | uint32_t dma_enable; /*!< USB DMA state. |
98 | (HCD_SPEED_xxx, HCD_SPEED_xxx) */ |
98 | If DMA is not supported this parameter shall be set by default to zero */ |
99 | 99 | #endif /* defined (USB_OTG_FS) */ |
|
100 | uint32_t dma_enable; /*!< Enable or disable of the USB embedded DMA used only for OTG HS. */ |
100 | |
101 | 101 | uint32_t speed; /*!< USB Core speed. |
|
102 | uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. */ |
102 | This parameter can be any value of @ref PCD_Speed/HCD_Speed |
103 | 103 | (HCD_SPEED_xxx, HCD_SPEED_xxx) */ |
|
104 | uint32_t phy_itface; /*!< Select the used PHY interface. |
104 | |
105 | This parameter can be any value of @ref PCD_PHY_Module/HCD_PHY_Module */ |
105 | uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. */ |
106 | 106 | ||
107 | uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */ |
107 | uint32_t phy_itface; /*!< Select the used PHY interface. |
108 | 108 | This parameter can be any value of @ref PCD_PHY_Module/HCD_PHY_Module */ |
|
109 | uint32_t low_power_enable; /*!< Enable or disable the low power mode. */ |
109 | |
110 | 110 | uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */ |
|
111 | uint32_t lpm_enable; /*!< Enable or disable Link Power Management. */ |
111 | |
112 | 112 | uint32_t low_power_enable; /*!< Enable or disable the low Power Mode. */ |
|
113 | uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */ |
113 | |
114 | 114 | uint32_t lpm_enable; /*!< Enable or disable Link Power Management. */ |
|
115 | uint32_t vbus_sensing_enable; /*!< Enable or disable the VBUS Sensing feature. */ |
115 | |
116 | 116 | uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */ |
|
117 | uint32_t use_dedicated_ep1; /*!< Enable or disable the use of the dedicated EP1 interrupt. */ |
117 | |
118 | 118 | #if defined (USB_OTG_FS) |
|
119 | uint32_t use_external_vbus; /*!< Enable or disable the use of the external VBUS. */ |
119 | uint32_t vbus_sensing_enable; /*!< Enable or disable the VBUS Sensing feature. */ |
120 | 120 | ||
121 | } USB_OTG_CfgTypeDef; |
121 | uint32_t use_dedicated_ep1; /*!< Enable or disable the use of the dedicated EP1 interrupt. */ |
122 | 122 | ||
123 | typedef struct |
123 | uint32_t use_external_vbus; /*!< Enable or disable the use of the external VBUS. */ |
124 | { |
124 | #endif /* defined (USB_OTG_FS) */ |
125 | uint8_t num; /*!< Endpoint number |
125 | } USB_CfgTypeDef; |
126 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
126 | |
127 | 127 | typedef struct |
|
128 | uint8_t is_in; /*!< Endpoint direction |
128 | { |
129 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
129 | uint8_t num; /*!< Endpoint number |
130 | 130 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
|
131 | uint8_t is_stall; /*!< Endpoint stall condition |
131 | |
132 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
132 | uint8_t is_in; /*!< Endpoint direction |
133 | 133 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
|
134 | uint8_t type; /*!< Endpoint type |
134 | |
135 | This parameter can be any value of @ref USB_LL_EP_Type */ |
135 | uint8_t is_stall; /*!< Endpoint stall condition |
136 | 136 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
|
137 | uint8_t data_pid_start; /*!< Initial data PID |
137 | |
138 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
138 | #if defined (USB_OTG_FS) |
139 | 139 | uint8_t is_iso_incomplete; /*!< Endpoint isoc condition |
|
140 | uint8_t even_odd_frame; /*!< IFrame parity |
140 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
141 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
141 | #endif /* defined (USB_OTG_FS) */ |
142 | 142 | ||
143 | uint16_t tx_fifo_num; /*!< Transmission FIFO number |
143 | uint8_t type; /*!< Endpoint type |
144 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
144 | This parameter can be any value of @ref USB_LL_EP_Type */ |
145 | 145 | ||
146 | uint32_t maxpacket; /*!< Endpoint Max packet size |
146 | uint8_t data_pid_start; /*!< Initial data PID |
147 | This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ |
147 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
148 | 148 | ||
149 | uint8_t *xfer_buff; /*!< Pointer to transfer buffer */ |
149 | #if defined (USB) |
150 | 150 | uint16_t pmaadress; /*!< PMA Address |
|
151 | uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address */ |
151 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
152 | 152 | ||
153 | uint32_t xfer_len; /*!< Current transfer length */ |
153 | uint16_t pmaaddr0; /*!< PMA Address0 |
154 | 154 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
|
155 | uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */ |
155 | |
156 | } USB_OTG_EPTypeDef; |
156 | uint16_t pmaaddr1; /*!< PMA Address1 |
157 | 157 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
|
158 | typedef struct |
158 | |
159 | { |
159 | uint8_t doublebuffer; /*!< Double buffer enable |
160 | uint8_t dev_addr; /*!< USB device address. |
160 | This parameter can be 0 or 1 */ |
161 | This parameter must be a number between Min_Data = 1 and Max_Data = 255 */ |
161 | #endif /* defined (USB) */ |
162 | 162 | ||
163 | uint8_t ch_num; /*!< Host channel number. |
163 | uint32_t maxpacket; /*!< Endpoint Max packet size |
164 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
164 | This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ |
165 | 165 | ||
166 | uint8_t ep_num; /*!< Endpoint number. |
166 | uint8_t *xfer_buff; /*!< Pointer to transfer buffer */ |
167 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
167 | |
168 | 168 | uint32_t xfer_len; /*!< Current transfer length */ |
|
169 | uint8_t ep_is_in; /*!< Endpoint direction |
169 | |
170 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
170 | uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */ |
171 | 171 | ||
172 | uint8_t speed; /*!< USB Host Channel speed. |
172 | #if defined (USB_OTG_FS) |
173 | This parameter can be any value of @ref HCD_Device_Speed: |
173 | uint8_t even_odd_frame; /*!< IFrame parity |
174 | (HCD_DEVICE_SPEED_xxx) */ |
174 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
175 | 175 | ||
176 | uint8_t do_ping; /*!< Enable or disable the use of the PING protocol for HS mode. */ |
176 | uint16_t tx_fifo_num; /*!< Transmission FIFO number |
177 | 177 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
|
178 | uint8_t process_ping; /*!< Execute the PING protocol for HS mode. */ |
178 | |
179 | 179 | uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address */ |
|
180 | uint8_t ep_type; /*!< Endpoint Type. |
180 | |
181 | This parameter can be any value of @ref USB_LL_EP_Type */ |
181 | uint32_t xfer_size; /*!< requested transfer size */ |
182 | 182 | #endif /* defined (USB_OTG_FS) */ |
|
183 | uint16_t max_packet; /*!< Endpoint Max packet size. |
183 | |
184 | This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ |
184 | #if defined (USB) |
185 | 185 | uint32_t xfer_len_db; /*!< double buffer transfer length used with bulk double buffer in */ |
|
186 | uint8_t data_pid; /*!< Initial data PID. |
186 | |
187 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
187 | uint8_t xfer_fill_db; /*!< double buffer Need to Fill new buffer used with bulk_in */ |
188 | 188 | #endif /* defined (USB) */ |
|
189 | uint8_t *xfer_buff; /*!< Pointer to transfer buffer. */ |
189 | } USB_EPTypeDef; |
190 | 190 | ||
191 | uint32_t XferSize; /*!< OTG Channel transfer size. */ |
191 | typedef struct |
192 | 192 | { |
|
193 | uint32_t xfer_len; /*!< Current transfer length. */ |
193 | uint8_t dev_addr; /*!< USB device address. |
194 | 194 | This parameter must be a number between Min_Data = 1 and Max_Data = 255 */ |
|
195 | uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer. */ |
195 | |
196 | 196 | uint8_t ch_num; /*!< Host channel number. |
|
197 | uint8_t toggle_in; /*!< IN transfer current toggle flag. |
197 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
198 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
198 | |
199 | 199 | uint8_t ep_num; /*!< Endpoint number. |
|
200 | uint8_t toggle_out; /*!< OUT transfer current toggle flag |
200 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
201 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
201 | |
202 | 202 | uint8_t ep_is_in; /*!< Endpoint direction |
|
203 | uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address. */ |
203 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
204 | 204 | ||
205 | uint32_t ErrCnt; /*!< Host channel error count. */ |
205 | uint8_t speed; /*!< USB Host Channel speed. |
206 | 206 | This parameter can be any value of @ref HCD_Device_Speed: |
|
207 | USB_OTG_URBStateTypeDef urb_state; /*!< URB state. |
207 | (HCD_DEVICE_SPEED_xxx) */ |
208 | This parameter can be any value of @ref USB_OTG_URBStateTypeDef */ |
208 | |
209 | 209 | uint8_t do_ping; /*!< Enable or disable the use of the PING protocol for HS mode. */ |
|
210 | USB_OTG_HCStateTypeDef state; /*!< Host Channel state. |
210 | |
211 | This parameter can be any value of @ref USB_OTG_HCStateTypeDef */ |
211 | uint8_t hub_port_nbr; /*!< USB HUB port number */ |
212 | } USB_OTG_HCTypeDef; |
212 | uint8_t hub_addr; /*!< USB HUB address */ |
213 | #endif /* defined (USB_OTG_FS) */ |
213 | |
214 | 214 | uint8_t ep_type; /*!< Endpoint Type. |
|
215 | #if defined (USB) |
215 | This parameter can be any value of @ref USB_LL_EP_Type */ |
216 | 216 | ||
217 | typedef enum |
217 | uint16_t max_packet; /*!< Endpoint Max packet size. |
218 | { |
218 | This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ |
219 | USB_DEVICE_MODE = 0 |
219 | |
220 | } USB_ModeTypeDef; |
220 | uint8_t data_pid; /*!< Initial data PID. |
221 | 221 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
|
222 | /** |
222 | |
223 | * @brief USB Initialization Structure definition |
223 | uint8_t *xfer_buff; /*!< Pointer to transfer buffer. */ |
224 | */ |
224 | |
225 | typedef struct |
225 | uint32_t XferSize; /*!< OTG Channel transfer size. */ |
226 | { |
226 | |
227 | uint32_t dev_endpoints; /*!< Device Endpoints number. |
227 | uint32_t xfer_len; /*!< Current transfer length. */ |
228 | This parameter depends on the used USB core. |
228 | |
229 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
229 | uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer. */ |
230 | 230 | ||
231 | uint32_t speed; /*!< USB Core speed. |
231 | uint8_t toggle_in; /*!< IN transfer current toggle flag. |
232 | This parameter can be any value of @ref PCD_Speed/HCD_Speed |
232 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
233 | (HCD_SPEED_xxx, HCD_SPEED_xxx) */ |
233 | |
234 | 234 | uint8_t toggle_out; /*!< OUT transfer current toggle flag |
|
235 | uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. */ |
235 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
236 | 236 | ||
237 | uint32_t phy_itface; /*!< Select the used PHY interface. |
237 | uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address. */ |
238 | This parameter can be any value of @ref PCD_PHY_Module/HCD_PHY_Module */ |
238 | |
239 | 239 | uint32_t ErrCnt; /*!< Host channel error count. */ |
|
240 | uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */ |
240 | |
241 | 241 | USB_URBStateTypeDef urb_state; /*!< URB state. |
|
242 | uint32_t low_power_enable; /*!< Enable or disable Low Power mode */ |
242 | This parameter can be any value of @ref USB_URBStateTypeDef */ |
243 | 243 | ||
244 | uint32_t lpm_enable; /*!< Enable or disable Battery charging. */ |
244 | USB_HCStateTypeDef state; /*!< Host Channel state. |
245 | 245 | This parameter can be any value of @ref USB_HCStateTypeDef */ |
|
246 | uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */ |
246 | } USB_HCTypeDef; |
247 | } USB_CfgTypeDef; |
247 | |
248 | 248 | #if defined (USB_OTG_FS) |
|
249 | typedef struct |
249 | typedef USB_ModeTypeDef USB_OTG_ModeTypeDef; |
250 | { |
250 | typedef USB_CfgTypeDef USB_OTG_CfgTypeDef; |
251 | uint8_t num; /*!< Endpoint number |
251 | typedef USB_EPTypeDef USB_OTG_EPTypeDef; |
252 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
252 | typedef USB_URBStateTypeDef USB_OTG_URBStateTypeDef; |
253 | 253 | typedef USB_HCStateTypeDef USB_OTG_HCStateTypeDef; |
|
254 | uint8_t is_in; /*!< Endpoint direction |
254 | typedef USB_HCTypeDef USB_OTG_HCTypeDef; |
255 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
255 | #endif /* defined (USB_OTG_FS) */ |
256 | 256 | ||
257 | uint8_t is_stall; /*!< Endpoint stall condition |
257 | /* Exported constants --------------------------------------------------------*/ |
258 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
258 | |
259 | 259 | /** @defgroup PCD_Exported_Constants PCD Exported Constants |
|
260 | uint8_t type; /*!< Endpoint type |
260 | * @{ |
261 | This parameter can be any value of @ref USB_EP_Type */ |
261 | */ |
262 | 262 | ||
263 | uint8_t data_pid_start; /*!< Initial data PID |
263 | #if defined (USB_OTG_FS) |
264 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
264 | /** @defgroup USB_OTG_CORE VERSION ID |
265 | 265 | * @{ |
|
266 | uint16_t pmaadress; /*!< PMA Address |
266 | */ |
267 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
267 | #define USB_OTG_CORE_ID_300A 0x4F54300AU |
268 | 268 | #define USB_OTG_CORE_ID_310A 0x4F54310AU |
|
269 | uint16_t pmaaddr0; /*!< PMA Address0 |
269 | /** |
270 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
270 | * @} |
271 | 271 | */ |
|
272 | uint16_t pmaaddr1; /*!< PMA Address1 |
272 | |
273 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
273 | /** @defgroup USB_Core_Mode_ USB Core Mode |
274 | 274 | * @{ |
|
275 | uint8_t doublebuffer; /*!< Double buffer enable |
275 | */ |
276 | This parameter can be 0 or 1 */ |
276 | #define USB_OTG_MODE_DEVICE 0U |
277 | 277 | #define USB_OTG_MODE_HOST 1U |
|
278 | uint16_t tx_fifo_num; /*!< This parameter is not required by USB Device FS peripheral, it is used |
278 | #define USB_OTG_MODE_DRD 2U |
279 | only by USB OTG FS peripheral |
279 | /** |
280 | This parameter is added to ensure compatibility across USB peripherals */ |
280 | * @} |
281 | 281 | */ |
|
282 | uint32_t maxpacket; /*!< Endpoint Max packet size |
282 | |
283 | This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ |
283 | /** @defgroup USB_LL_Core_Speed USB Low Layer Core Speed |
284 | 284 | * @{ |
|
285 | uint8_t *xfer_buff; /*!< Pointer to transfer buffer */ |
285 | */ |
286 | 286 | #define USB_OTG_SPEED_FULL 3U |
|
287 | uint32_t xfer_len; /*!< Current transfer length */ |
287 | /** |
288 | 288 | * @} |
|
289 | uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */ |
289 | */ |
290 | 290 | ||
291 | uint32_t xfer_len_db; /*!< double buffer transfer length used with bulk double buffer in */ |
291 | /** @defgroup USB_LL_Core_PHY USB Low Layer Core PHY |
292 | 292 | * @{ |
|
293 | uint8_t xfer_fill_db; /*!< double buffer Need to Fill new buffer used with bulk_in */ |
293 | */ |
294 | 294 | #define USB_OTG_EMBEDDED_PHY 2U |
|
295 | } USB_EPTypeDef; |
295 | /** |
296 | #endif /* defined (USB) */ |
296 | * @} |
297 | 297 | */ |
|
298 | /* Exported constants --------------------------------------------------------*/ |
298 | |
299 | 299 | /** @defgroup USB_LL_Turnaround_Timeout Turnaround Timeout Value |
|
300 | /** @defgroup PCD_Exported_Constants PCD Exported Constants |
300 | * @{ |
301 | * @{ |
301 | */ |
302 | */ |
302 | #ifndef USBD_FS_TRDT_VALUE |
303 | 303 | #define USBD_FS_TRDT_VALUE 5U |
|
304 | #if defined (USB_OTG_FS) |
304 | #define USBD_DEFAULT_TRDT_VALUE 9U |
305 | /** @defgroup USB_OTG_CORE VERSION ID |
305 | #endif /* USBD_HS_TRDT_VALUE */ |
306 | * @{ |
306 | /** |
307 | */ |
307 | * @} |
308 | #define USB_OTG_CORE_ID_300A 0x4F54300AU |
308 | */ |
309 | #define USB_OTG_CORE_ID_310A 0x4F54310AU |
309 | |
310 | /** |
310 | /** @defgroup USB_LL_Core_MPS USB Low Layer Core MPS |
311 | * @} |
311 | * @{ |
312 | */ |
312 | */ |
313 | 313 | #define USB_OTG_FS_MAX_PACKET_SIZE 64U |
|
314 | /** @defgroup USB_Core_Mode_ USB Core Mode |
314 | #define USB_OTG_MAX_EP0_SIZE 64U |
315 | * @{ |
315 | /** |
316 | */ |
316 | * @} |
317 | #define USB_OTG_MODE_DEVICE 0U |
317 | */ |
318 | #define USB_OTG_MODE_HOST 1U |
318 | |
319 | #define USB_OTG_MODE_DRD 2U |
319 | /** @defgroup USB_LL_Core_PHY_Frequency USB Low Layer Core PHY Frequency |
320 | /** |
320 | * @{ |
321 | * @} |
321 | */ |
322 | */ |
322 | #define DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ (0U << 1) |
323 | 323 | #define DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ (1U << 1) |
|
324 | /** @defgroup USB_LL Device Speed |
324 | #define DSTS_ENUMSPD_FS_PHY_48MHZ (3U << 1) |
325 | * @{ |
325 | /** |
326 | */ |
326 | * @} |
327 | #define USBD_FS_SPEED 2U |
327 | */ |
328 | #define USBH_FSLS_SPEED 1U |
328 | |
329 | /** |
329 | /** @defgroup USB_LL_CORE_Frame_Interval USB Low Layer Core Frame Interval |
330 | * @} |
330 | * @{ |
331 | */ |
331 | */ |
332 | 332 | #define DCFG_FRAME_INTERVAL_80 0U |
|
333 | /** @defgroup USB_LL_Core_Speed USB Low Layer Core Speed |
333 | #define DCFG_FRAME_INTERVAL_85 1U |
334 | * @{ |
334 | #define DCFG_FRAME_INTERVAL_90 2U |
335 | */ |
335 | #define DCFG_FRAME_INTERVAL_95 3U |
336 | #define USB_OTG_SPEED_FULL 3U |
336 | /** |
337 | /** |
337 | * @} |
338 | * @} |
338 | */ |
339 | */ |
339 | #endif /* defined (USB_OTG_FS) */ |
340 | 340 | /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS |
|
341 | /** @defgroup USB_LL_Core_PHY USB Low Layer Core PHY |
341 | * @{ |
342 | * @{ |
342 | */ |
343 | */ |
343 | #define EP_MPS_64 0U |
344 | #define USB_OTG_ULPI_PHY 1U |
344 | #define EP_MPS_32 1U |
345 | #define USB_OTG_EMBEDDED_PHY 2U |
345 | #define EP_MPS_16 2U |
346 | /** |
346 | #define EP_MPS_8 3U |
347 | * @} |
347 | /** |
348 | */ |
348 | * @} |
349 | 349 | */ |
|
350 | /** @defgroup USB_LL_Turnaround_Timeout Turnaround Timeout Value |
350 | |
351 | * @{ |
351 | /** @defgroup USB_LL_EP_Type USB Low Layer EP Type |
352 | */ |
352 | * @{ |
353 | #ifndef USBD_FS_TRDT_VALUE |
353 | */ |
354 | #define USBD_FS_TRDT_VALUE 5U |
354 | #define EP_TYPE_CTRL 0U |
355 | #define USBD_DEFAULT_TRDT_VALUE 9U |
355 | #define EP_TYPE_ISOC 1U |
356 | #endif /* USBD_HS_TRDT_VALUE */ |
356 | #define EP_TYPE_BULK 2U |
357 | /** |
357 | #define EP_TYPE_INTR 3U |
358 | * @} |
358 | #define EP_TYPE_MSK 3U |
359 | */ |
359 | /** |
360 | 360 | * @} |
|
361 | /** @defgroup USB_LL_Core_MPS USB Low Layer Core MPS |
361 | */ |
362 | * @{ |
362 | |
363 | */ |
363 | /** @defgroup USB_LL_EP_Speed USB Low Layer EP Speed |
364 | #define USB_OTG_FS_MAX_PACKET_SIZE 64U |
364 | * @{ |
365 | #define USB_OTG_MAX_EP0_SIZE 64U |
365 | */ |
366 | /** |
366 | #define EP_SPEED_LOW 0U |
367 | * @} |
367 | #define EP_SPEED_FULL 1U |
368 | */ |
368 | #define EP_SPEED_HIGH 2U |
369 | 369 | /** |
|
370 | /** @defgroup USB_LL_Core_PHY_Frequency USB Low Layer Core PHY Frequency |
370 | * @} |
371 | * @{ |
371 | */ |
372 | */ |
372 | |
373 | #define DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ (0U << 1) |
373 | /** @defgroup USB_LL_CH_PID_Type USB Low Layer Channel PID Type |
374 | #define DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ (1U << 1) |
374 | * @{ |
375 | #define DSTS_ENUMSPD_FS_PHY_48MHZ (3U << 1) |
375 | */ |
376 | /** |
376 | #define HC_PID_DATA0 0U |
377 | * @} |
377 | #define HC_PID_DATA2 1U |
378 | */ |
378 | #define HC_PID_DATA1 2U |
379 | 379 | #define HC_PID_SETUP 3U |
|
380 | /** @defgroup USB_LL_CORE_Frame_Interval USB Low Layer Core Frame Interval |
380 | /** |
381 | * @{ |
381 | * @} |
382 | */ |
382 | */ |
383 | #define DCFG_FRAME_INTERVAL_80 0U |
383 | |
384 | #define DCFG_FRAME_INTERVAL_85 1U |
384 | /** @defgroup USB_LL Device Speed |
385 | #define DCFG_FRAME_INTERVAL_90 2U |
385 | * @{ |
386 | #define DCFG_FRAME_INTERVAL_95 3U |
386 | */ |
387 | /** |
387 | #define USBD_FS_SPEED 2U |
388 | * @} |
388 | #define USBH_FSLS_SPEED 1U |
389 | */ |
389 | /** |
390 | 390 | * @} |
|
391 | /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS |
391 | */ |
392 | * @{ |
392 | |
393 | */ |
393 | #if defined (USB_OTG_FS) |
394 | #define EP_MPS_64 0U |
394 | /** @defgroup USB_LL_STS_Defines USB Low Layer STS Defines |
395 | #define EP_MPS_32 1U |
395 | * @{ |
396 | #define EP_MPS_16 2U |
396 | */ |
397 | #define EP_MPS_8 3U |
397 | #define STS_GOUT_NAK 1U |
398 | /** |
398 | #define STS_DATA_UPDT 2U |
399 | * @} |
399 | #define STS_XFER_COMP 3U |
400 | */ |
400 | #define STS_SETUP_COMP 4U |
401 | 401 | #define STS_SETUP_UPDT 6U |
|
402 | /** @defgroup USB_LL_EP_Speed USB Low Layer EP Speed |
402 | /** |
403 | * @{ |
403 | * @} |
404 | */ |
404 | */ |
405 | #define EP_SPEED_LOW 0U |
405 | |
406 | #define EP_SPEED_FULL 1U |
406 | /** @defgroup USB_LL_HCFG_SPEED_Defines USB Low Layer HCFG Speed Defines |
407 | #define EP_SPEED_HIGH 2U |
407 | * @{ |
408 | /** |
408 | */ |
409 | * @} |
409 | #define HCFG_30_60_MHZ 0U |
410 | */ |
410 | #define HCFG_48_MHZ 1U |
411 | 411 | #define HCFG_6_MHZ 2U |
|
412 | /** @defgroup USB_LL_EP_Type USB Low Layer EP Type |
412 | /** |
413 | * @{ |
413 | * @} |
414 | */ |
414 | */ |
415 | #define EP_TYPE_CTRL 0U |
415 | |
416 | #define EP_TYPE_ISOC 1U |
416 | /** @defgroup USB_LL_HFIR_Defines USB Low Layer frame interval Defines |
417 | #define EP_TYPE_BULK 2U |
417 | * @{ |
418 | #define EP_TYPE_INTR 3U |
418 | */ |
419 | #define EP_TYPE_MSK 3U |
419 | #define HFIR_6_MHZ 6000U |
420 | /** |
420 | #define HFIR_60_MHZ 60000U |
421 | * @} |
421 | #define HFIR_48_MHZ 48000U |
422 | */ |
422 | /** |
423 | 423 | * @} |
|
424 | /** @defgroup USB_LL_STS_Defines USB Low Layer STS Defines |
424 | */ |
425 | * @{ |
425 | |
426 | */ |
426 | /** @defgroup USB_LL_HPRT0_PRTSPD_SPEED_Defines USB Low Layer HPRT0 PRTSPD Speed Defines |
427 | #define STS_GOUT_NAK 1U |
427 | * @{ |
428 | #define STS_DATA_UPDT 2U |
428 | */ |
429 | #define STS_XFER_COMP 3U |
429 | #define HPRT0_PRTSPD_HIGH_SPEED 0U |
430 | #define STS_SETUP_COMP 4U |
430 | #define HPRT0_PRTSPD_FULL_SPEED 1U |
431 | #define STS_SETUP_UPDT 6U |
431 | #define HPRT0_PRTSPD_LOW_SPEED 2U |
432 | /** |
432 | /** |
433 | * @} |
433 | * @} |
434 | */ |
434 | */ |
435 | 435 | ||
436 | /** @defgroup USB_LL_HCFG_SPEED_Defines USB Low Layer HCFG Speed Defines |
436 | #define HCCHAR_CTRL 0U |
437 | * @{ |
437 | #define HCCHAR_ISOC 1U |
438 | */ |
438 | #define HCCHAR_BULK 2U |
439 | #define HCFG_30_60_MHZ 0U |
439 | #define HCCHAR_INTR 3U |
440 | #define HCFG_48_MHZ 1U |
440 | |
441 | #define HCFG_6_MHZ 2U |
441 | #define GRXSTS_PKTSTS_IN 2U |
442 | /** |
442 | #define GRXSTS_PKTSTS_IN_XFER_COMP 3U |
443 | * @} |
443 | #define GRXSTS_PKTSTS_DATA_TOGGLE_ERR 5U |
444 | */ |
444 | #define GRXSTS_PKTSTS_CH_HALTED 7U |
445 | 445 | ||
446 | /** @defgroup USB_LL_HPRT0_PRTSPD_SPEED_Defines USB Low Layer HPRT0 PRTSPD Speed Defines |
446 | #define CLEAR_INTERRUPT_MASK 0xFFFFFFFFU |
447 | * @{ |
447 | |
448 | */ |
448 | #define HC_MAX_PKT_CNT 256U |
449 | #define HPRT0_PRTSPD_HIGH_SPEED 0U |
449 | |
450 | #define HPRT0_PRTSPD_FULL_SPEED 1U |
450 | #define USBx_PCGCCTL *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_PCGCCTL_BASE) |
451 | #define HPRT0_PRTSPD_LOW_SPEED 2U |
451 | #define USBx_HPRT0 *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_HOST_PORT_BASE) |
452 | /** |
452 | |
453 | * @} |
453 | #define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)(USBx_BASE + USB_OTG_DEVICE_BASE)) |
454 | */ |
454 | #define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)(USBx_BASE\ |
455 | 455 | + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) |
|
456 | #define HCCHAR_CTRL 0U |
456 | |
457 | #define HCCHAR_ISOC 1U |
457 | #define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)(USBx_BASE\ |
458 | #define HCCHAR_BULK 2U |
458 | + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) |
459 | #define HCCHAR_INTR 3U |
459 | |
460 | 460 | #define USBx_DFIFO(i) *(__IO uint32_t *)(USBx_BASE + USB_OTG_FIFO_BASE + ((i) * USB_OTG_FIFO_SIZE)) |
|
461 | #define HC_PID_DATA0 0U |
461 | |
462 | #define HC_PID_DATA2 1U |
462 | #define USBx_HOST ((USB_OTG_HostTypeDef *)(USBx_BASE + USB_OTG_HOST_BASE)) |
463 | #define HC_PID_DATA1 2U |
463 | #define USBx_HC(i) ((USB_OTG_HostChannelTypeDef *)(USBx_BASE\ |
464 | #define HC_PID_SETUP 3U |
464 | + USB_OTG_HOST_CHANNEL_BASE\ |
465 | 465 | + ((i) * USB_OTG_HOST_CHANNEL_SIZE))) |
|
466 | #define GRXSTS_PKTSTS_IN 2U |
466 | |
467 | #define GRXSTS_PKTSTS_IN_XFER_COMP 3U |
467 | |
468 | #define GRXSTS_PKTSTS_DATA_TOGGLE_ERR 5U |
468 | #define EP_ADDR_MSK 0xFU |
469 | #define GRXSTS_PKTSTS_CH_HALTED 7U |
469 | #endif /* defined (USB_OTG_FS) */ |
470 | 470 | ||
471 | #define USBx_PCGCCTL *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_PCGCCTL_BASE) |
471 | #if defined (USB) |
472 | #define USBx_HPRT0 *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_HOST_PORT_BASE) |
472 | #define BTABLE_ADDRESS 0x000U |
473 | 473 | #define PMA_ACCESS 2U |
|
474 | #define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)(USBx_BASE + USB_OTG_DEVICE_BASE)) |
474 | |
475 | #define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)(USBx_BASE\ |
475 | #ifndef USB_EP_RX_STRX |
476 | + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) |
476 | #define USB_EP_RX_STRX (0x3U << 12) |
477 | 477 | #endif /* USB_EP_RX_STRX */ |
|
478 | #define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)(USBx_BASE\ |
478 | |
479 | + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) |
479 | #define EP_ADDR_MSK 0x7U |
480 | 480 | ||
481 | #define USBx_DFIFO(i) *(__IO uint32_t *)(USBx_BASE + USB_OTG_FIFO_BASE + ((i) * USB_OTG_FIFO_SIZE)) |
481 | #ifndef USE_USB_DOUBLE_BUFFER |
482 | 482 | #define USE_USB_DOUBLE_BUFFER 1U |
|
483 | #define USBx_HOST ((USB_OTG_HostTypeDef *)(USBx_BASE + USB_OTG_HOST_BASE)) |
483 | #endif /* USE_USB_DOUBLE_BUFFER */ |
484 | #define USBx_HC(i) ((USB_OTG_HostChannelTypeDef *)(USBx_BASE\ |
484 | #endif /* defined (USB) */ |
485 | + USB_OTG_HOST_CHANNEL_BASE\ |
485 | |
486 | + ((i) * USB_OTG_HOST_CHANNEL_SIZE))) |
486 | /** |
487 | 487 | * @} |
|
488 | #endif /* defined (USB_OTG_FS) */ |
488 | */ |
489 | 489 | ||
490 | #if defined (USB) |
490 | /* Exported macro ------------------------------------------------------------*/ |
491 | /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS |
491 | /** @defgroup USB_LL_Exported_Macros USB Low Layer Exported Macros |
492 | * @{ |
492 | * @{ |
493 | */ |
493 | */ |
494 | #define EP_MPS_64 0U |
494 | #if defined (USB_OTG_FS) |
495 | #define EP_MPS_32 1U |
495 | #define USB_MASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK &= ~(__INTERRUPT__)) |
496 | #define EP_MPS_16 2U |
496 | #define USB_UNMASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK |= (__INTERRUPT__)) |
497 | #define EP_MPS_8 3U |
497 | |
498 | /** |
498 | #define CLEAR_IN_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_INEP(__EPNUM__)->DIEPINT = (__INTERRUPT__)) |
499 | * @} |
499 | #define CLEAR_OUT_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_OUTEP(__EPNUM__)->DOEPINT = (__INTERRUPT__)) |
500 | */ |
500 | #endif /* defined (USB_OTG_FS) */ |
501 | 501 | /** |
|
502 | /** @defgroup USB_LL_EP_Type USB Low Layer EP Type |
502 | * @} |
503 | * @{ |
503 | */ |
504 | */ |
504 | |
505 | #define EP_TYPE_CTRL 0U |
505 | /* Exported functions --------------------------------------------------------*/ |
506 | #define EP_TYPE_ISOC 1U |
506 | /** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions |
507 | #define EP_TYPE_BULK 2U |
507 | * @{ |
508 | #define EP_TYPE_INTR 3U |
508 | */ |
509 | #define EP_TYPE_MSK 3U |
509 | #if defined (USB_OTG_FS) |
510 | /** |
510 | HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg); |
511 | * @} |
511 | HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg); |
512 | */ |
512 | HAL_StatusTypeDef USB_EnableGlobalInt(USB_OTG_GlobalTypeDef *USBx); |
513 | 513 | HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx); |
|
514 | /** @defgroup USB_LL Device Speed |
514 | HAL_StatusTypeDef USB_SetTurnaroundTime(USB_OTG_GlobalTypeDef *USBx, uint32_t hclk, uint8_t speed); |
515 | * @{ |
515 | HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx, USB_ModeTypeDef mode); |
516 | */ |
516 | HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx, uint8_t speed); |
517 | #define USBD_FS_SPEED 2U |
517 | HAL_StatusTypeDef USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx); |
518 | /** |
518 | HAL_StatusTypeDef USB_FlushTxFifo(USB_OTG_GlobalTypeDef *USBx, uint32_t num); |
519 | * @} |
519 | HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
520 | */ |
520 | HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
521 | 521 | HAL_StatusTypeDef USB_ActivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
|
522 | #define BTABLE_ADDRESS 0x000U |
522 | HAL_StatusTypeDef USB_DeactivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
523 | #define PMA_ACCESS 2U |
523 | HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
524 | #endif /* defined (USB) */ |
524 | HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, |
525 | #if defined (USB_OTG_FS) |
525 | uint8_t ch_ep_num, uint16_t len); |
526 | #define EP_ADDR_MSK 0xFU |
526 | |
527 | #endif /* defined (USB_OTG_FS) */ |
527 | void *USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len); |
528 | #if defined (USB) |
528 | HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
529 | #define EP_ADDR_MSK 0x7U |
529 | HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
530 | #endif /* defined (USB) */ |
530 | HAL_StatusTypeDef USB_EPStopXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
531 | /** |
531 | HAL_StatusTypeDef USB_SetDevAddress(USB_OTG_GlobalTypeDef *USBx, uint8_t address); |
532 | * @} |
532 | HAL_StatusTypeDef USB_DevConnect(USB_OTG_GlobalTypeDef *USBx); |
533 | */ |
533 | HAL_StatusTypeDef USB_DevDisconnect(USB_OTG_GlobalTypeDef *USBx); |
534 | 534 | HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx); |
|
535 | /* Exported macro ------------------------------------------------------------*/ |
535 | HAL_StatusTypeDef USB_ActivateSetup(USB_OTG_GlobalTypeDef *USBx); |
536 | /** @defgroup USB_LL_Exported_Macros USB Low Layer Exported Macros |
536 | HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t *psetup); |
537 | * @{ |
537 | uint8_t USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx); |
538 | */ |
538 | uint32_t USB_GetMode(USB_OTG_GlobalTypeDef *USBx); |
539 | #if defined (USB_OTG_FS) |
539 | uint32_t USB_ReadInterrupts(USB_OTG_GlobalTypeDef const *USBx); |
540 | #define USB_MASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK &= ~(__INTERRUPT__)) |
540 | uint32_t USB_ReadChInterrupts(USB_OTG_GlobalTypeDef *USBx, uint8_t chnum); |
541 | #define USB_UNMASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK |= (__INTERRUPT__)) |
541 | uint32_t USB_ReadDevAllOutEpInterrupt(USB_OTG_GlobalTypeDef *USBx); |
542 | 542 | uint32_t USB_ReadDevOutEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum); |
|
543 | #define CLEAR_IN_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_INEP(__EPNUM__)->DIEPINT = (__INTERRUPT__)) |
543 | uint32_t USB_ReadDevAllInEpInterrupt(USB_OTG_GlobalTypeDef *USBx); |
544 | #define CLEAR_OUT_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_OUTEP(__EPNUM__)->DOEPINT = (__INTERRUPT__)) |
544 | uint32_t USB_ReadDevInEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum); |
545 | #endif /* defined (USB_OTG_FS) */ |
545 | void USB_ClearInterrupts(USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt); |
546 | /** |
546 | |
547 | * @} |
547 | HAL_StatusTypeDef USB_HostInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg); |
548 | */ |
548 | HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx, uint8_t freq); |
549 | 549 | HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx); |
|
550 | /* Exported functions --------------------------------------------------------*/ |
550 | HAL_StatusTypeDef USB_DriveVbus(USB_OTG_GlobalTypeDef *USBx, uint8_t state); |
551 | /** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions |
551 | uint32_t USB_GetHostSpeed(USB_OTG_GlobalTypeDef const *USBx); |
552 | * @{ |
552 | uint32_t USB_GetCurrentFrame(USB_OTG_GlobalTypeDef const *USBx); |
553 | */ |
553 | HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num, |
554 | #if defined (USB_OTG_FS) |
554 | uint8_t epnum, uint8_t dev_address, uint8_t speed, |
555 | HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg); |
555 | uint8_t ep_type, uint16_t mps); |
556 | HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg); |
556 | HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, |
557 | HAL_StatusTypeDef USB_EnableGlobalInt(USB_OTG_GlobalTypeDef *USBx); |
557 | USB_OTG_HCTypeDef *hc); |
558 | HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx); |
558 | |
559 | HAL_StatusTypeDef USB_SetTurnaroundTime(USB_OTG_GlobalTypeDef *USBx, uint32_t hclk, uint8_t speed); |
559 | uint32_t USB_HC_ReadInterrupt(USB_OTG_GlobalTypeDef *USBx); |
560 | HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx, USB_ModeTypeDef mode); |
560 | HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx, uint8_t hc_num); |
561 | HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx, uint8_t speed); |
561 | HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num); |
562 | HAL_StatusTypeDef USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx); |
562 | HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx); |
563 | HAL_StatusTypeDef USB_FlushTxFifo(USB_OTG_GlobalTypeDef *USBx, uint32_t num); |
563 | HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx); |
564 | HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
564 | HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx); |
565 | HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
565 | #endif /* defined (USB_OTG_FS) */ |
566 | HAL_StatusTypeDef USB_ActivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
566 | |
567 | HAL_StatusTypeDef USB_DeactivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
567 | #if defined (USB) |
568 | HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
568 | HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg); |
569 | HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
569 | HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg); |
570 | HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, |
570 | HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx); |
571 | uint8_t ch_ep_num, uint16_t len); |
571 | HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx); |
572 | 572 | HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode); |
|
573 | void *USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len); |
573 | HAL_StatusTypeDef USB_SetDevSpeed(USB_TypeDef *USBx, uint8_t speed); |
574 | HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
574 | |
575 | HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
575 | HAL_StatusTypeDef USB_FlushRxFifo(USB_TypeDef const *USBx); |
576 | HAL_StatusTypeDef USB_SetDevAddress(USB_OTG_GlobalTypeDef *USBx, uint8_t address); |
576 | HAL_StatusTypeDef USB_FlushTxFifo(USB_TypeDef const *USBx, uint32_t num); |
577 | HAL_StatusTypeDef USB_DevConnect(USB_OTG_GlobalTypeDef *USBx); |
577 | |
578 | HAL_StatusTypeDef USB_DevDisconnect(USB_OTG_GlobalTypeDef *USBx); |
578 | #if defined (HAL_PCD_MODULE_ENABLED) |
579 | HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx); |
579 | HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
580 | HAL_StatusTypeDef USB_ActivateSetup(USB_OTG_GlobalTypeDef *USBx); |
580 | HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
581 | HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t *psetup); |
581 | HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
582 | uint8_t USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx); |
582 | HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
583 | uint32_t USB_GetMode(USB_OTG_GlobalTypeDef *USBx); |
583 | HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
584 | uint32_t USB_ReadInterrupts(USB_OTG_GlobalTypeDef *USBx); |
584 | HAL_StatusTypeDef USB_EPStopXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
585 | uint32_t USB_ReadDevAllOutEpInterrupt(USB_OTG_GlobalTypeDef *USBx); |
585 | #endif /* defined (HAL_PCD_MODULE_ENABLED) */ |
586 | uint32_t USB_ReadDevOutEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum); |
586 | |
587 | uint32_t USB_ReadDevAllInEpInterrupt(USB_OTG_GlobalTypeDef *USBx); |
587 | HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address); |
588 | uint32_t USB_ReadDevInEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum); |
588 | HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx); |
589 | void USB_ClearInterrupts(USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt); |
589 | HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx); |
590 | 590 | HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx); |
|
591 | HAL_StatusTypeDef USB_HostInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg); |
591 | HAL_StatusTypeDef USB_EP0_OutStart(USB_TypeDef *USBx, uint8_t *psetup); |
592 | HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx, uint8_t freq); |
592 | HAL_StatusTypeDef USB_WritePacket(USB_TypeDef *USBx, uint8_t *src, |
593 | HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx); |
593 | uint8_t ch_ep_num, uint16_t len); |
594 | HAL_StatusTypeDef USB_DriveVbus(USB_OTG_GlobalTypeDef *USBx, uint8_t state); |
594 | |
595 | uint32_t USB_GetHostSpeed(USB_OTG_GlobalTypeDef *USBx); |
595 | void *USB_ReadPacket(USB_TypeDef *USBx, uint8_t *dest, uint16_t len); |
596 | uint32_t USB_GetCurrentFrame(USB_OTG_GlobalTypeDef *USBx); |
596 | |
597 | HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num, |
597 | uint32_t USB_ReadInterrupts(USB_TypeDef const *USBx); |
598 | uint8_t epnum, uint8_t dev_address, uint8_t speed, |
598 | uint32_t USB_ReadDevAllOutEpInterrupt(USB_TypeDef *USBx); |
599 | uint8_t ep_type, uint16_t mps); |
599 | uint32_t USB_ReadDevOutEPInterrupt(USB_TypeDef *USBx, uint8_t epnum); |
600 | HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, |
600 | uint32_t USB_ReadDevAllInEpInterrupt(USB_TypeDef *USBx); |
601 | USB_OTG_HCTypeDef *hc); |
601 | uint32_t USB_ReadDevInEPInterrupt(USB_TypeDef *USBx, uint8_t epnum); |
602 | 602 | void USB_ClearInterrupts(USB_TypeDef *USBx, uint32_t interrupt); |
|
603 | uint32_t USB_HC_ReadInterrupt(USB_OTG_GlobalTypeDef *USBx); |
603 | HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx); |
604 | HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx, uint8_t hc_num); |
604 | HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx); |
605 | HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num); |
605 | |
606 | HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx); |
606 | void USB_WritePMA(USB_TypeDef const *USBx, uint8_t *pbUsrBuf, |
607 | HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx); |
607 | uint16_t wPMABufAddr, uint16_t wNBytes); |
608 | HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx); |
608 | |
609 | #endif /* defined (USB_OTG_FS) */ |
609 | void USB_ReadPMA(USB_TypeDef const *USBx, uint8_t *pbUsrBuf, |
610 | 610 | uint16_t wPMABufAddr, uint16_t wNBytes); |
|
611 | #if defined (USB) |
611 | #endif /* defined (USB) */ |
612 | HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg); |
612 | /** |
613 | HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg); |
613 | * @} |
614 | HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx); |
614 | */ |
615 | HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx); |
615 | |
616 | HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode); |
616 | /** |
617 | HAL_StatusTypeDef USB_SetDevSpeed(USB_TypeDef *USBx, uint8_t speed); |
617 | * @} |
618 | HAL_StatusTypeDef USB_FlushRxFifo(USB_TypeDef *USBx); |
618 | */ |
619 | HAL_StatusTypeDef USB_FlushTxFifo(USB_TypeDef *USBx, uint32_t num); |
619 | |
620 | 620 | /** |
|
621 | #if defined (HAL_PCD_MODULE_ENABLED) |
621 | * @} |
622 | HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
622 | */ |
623 | HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
623 | |
624 | HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
624 | /** |
625 | HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
625 | * @} |
626 | HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
626 | */ |
627 | #endif |
627 | #endif /* defined (USB) || defined (USB_OTG_FS) */ |
628 | 628 | ||
629 | HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address); |
629 | #ifdef __cplusplus |
630 | HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx); |
630 | } |
631 | HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx); |
631 | #endif /* __cplusplus */ |
632 | HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx); |
632 | |
633 | HAL_StatusTypeDef USB_EP0_OutStart(USB_TypeDef *USBx, uint8_t *psetup); |
633 | |
634 | HAL_StatusTypeDef USB_WritePacket(USB_TypeDef *USBx, uint8_t *src, |
634 | #endif /* STM32F1xx_LL_USB_H */ |
635 | uint8_t ch_ep_num, uint16_t len); |
- | |
636 | - | ||
637 | void *USB_ReadPacket(USB_TypeDef *USBx, uint8_t *dest, uint16_t len); |
- | |
638 | - | ||
639 | uint32_t USB_ReadInterrupts(USB_TypeDef *USBx); |
- | |
640 | uint32_t USB_ReadDevAllOutEpInterrupt(USB_TypeDef *USBx); |
- | |
641 | uint32_t USB_ReadDevOutEPInterrupt(USB_TypeDef *USBx, uint8_t epnum); |
- | |
642 | uint32_t USB_ReadDevAllInEpInterrupt(USB_TypeDef *USBx); |
- | |
643 | uint32_t USB_ReadDevInEPInterrupt(USB_TypeDef *USBx, uint8_t epnum); |
- | |
644 | void USB_ClearInterrupts(USB_TypeDef *USBx, uint32_t interrupt); |
- | |
645 | HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx); |
- | |
646 | HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx); |
- | |
647 | - | ||
648 | void USB_WritePMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, |
- | |
649 | uint16_t wPMABufAddr, uint16_t wNBytes); |
- | |
650 | - | ||
651 | void USB_ReadPMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, |
- | |
652 | uint16_t wPMABufAddr, uint16_t wNBytes); |
- | |
653 | #endif /* defined (USB) */ |
- | |
654 | /** |
- | |
655 | * @} |
- | |
656 | */ |
- | |
657 | - | ||
658 | /** |
- | |
659 | * @} |
- | |
660 | */ |
- | |
661 | - | ||
662 | /** |
- | |
663 | * @} |
- | |
664 | */ |
- | |
665 | - | ||
666 | /** |
- | |
667 | * @} |
- | |
668 | */ |
- | |
669 | #endif /* defined (USB) || defined (USB_OTG_FS) */ |
- | |
670 | - | ||
671 | #ifdef __cplusplus |
- | |
672 | } |
- | |
673 | #endif |
- | |
674 | - | ||
675 | - | ||
676 | #endif /* STM32F1xx_LL_USB_H */ |
- | |
677 | - | ||
678 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
- |