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