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</center></h2> |
||
10 | * |
||
11 | * Redistribution and use in source and binary forms, with or without modification, |
||
12 | * are permitted provided that the following conditions are met: |
||
13 | * 1. Redistributions of source code must retain the above copyright notice, |
||
14 | * this list of conditions and the following disclaimer. |
||
15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
||
16 | * this list of conditions and the following disclaimer in the documentation |
||
17 | * and/or other materials provided with the distribution. |
||
18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
||
19 | * may be used to endorse or promote products derived from this software |
||
20 | * without specific prior written permission. |
||
21 | * |
||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||
25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||
28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||
30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
32 | * |
||
33 | ****************************************************************************** |
||
34 | */ |
||
35 | |||
36 | /* Define to prevent recursive inclusion -------------------------------------*/ |
||
37 | #ifndef __STM32F1xx_LL_USB_H |
||
38 | #define __STM32F1xx_LL_USB_H |
||
39 | |||
40 | #ifdef __cplusplus |
||
41 | extern "C" { |
||
42 | #endif |
||
43 | |||
44 | #if defined(STM32F102x6) || defined(STM32F102xB) || \ |
||
45 | defined(STM32F103x6) || defined(STM32F103xB) || \ |
||
46 | defined(STM32F103xE) || defined(STM32F103xG) || \ |
||
47 | defined(STM32F105xC) || defined(STM32F107xC) |
||
48 | |||
49 | /* Includes ------------------------------------------------------------------*/ |
||
50 | #include "stm32f1xx_hal_def.h" |
||
51 | |||
52 | /** @addtogroup STM32F1xx_HAL_Driver |
||
53 | * @{ |
||
54 | */ |
||
55 | |||
56 | /** @addtogroup USB_LL |
||
57 | * @{ |
||
58 | */ |
||
59 | |||
60 | /* Exported types ------------------------------------------------------------*/ |
||
61 | /** @defgroup USB_LL_Exported_Types USB Low Layer Exported Types |
||
62 | * @{ |
||
63 | */ |
||
64 | /** |
||
65 | * @brief USB Mode definition |
||
66 | */ |
||
67 | typedef enum |
||
68 | { |
||
69 | USB_DEVICE_MODE = 0, |
||
70 | USB_HOST_MODE = 1, |
||
71 | USB_DRD_MODE = 2 |
||
72 | }USB_ModeTypeDef; |
||
73 | |||
74 | #if defined (USB_OTG_FS) |
||
75 | /** |
||
76 | * @brief URB States definition |
||
77 | */ |
||
78 | typedef enum { |
||
79 | URB_IDLE = 0, |
||
80 | URB_DONE, |
||
81 | URB_NOTREADY, |
||
82 | URB_NYET, |
||
83 | URB_ERROR, |
||
84 | URB_STALL |
||
85 | }USB_OTG_URBStateTypeDef; |
||
86 | |||
87 | /** |
||
88 | * @brief Host channel States definition |
||
89 | */ |
||
90 | typedef enum { |
||
91 | HC_IDLE = 0, |
||
92 | HC_XFRC, |
||
93 | HC_HALTED, |
||
94 | HC_NAK, |
||
95 | HC_NYET, |
||
96 | HC_STALL, |
||
97 | HC_XACTERR, |
||
98 | HC_BBLERR, |
||
99 | HC_DATATGLERR |
||
100 | }USB_OTG_HCStateTypeDef; |
||
101 | |||
102 | /** |
||
103 | * @brief USB OTG Initialization Structure definition |
||
104 | */ |
||
105 | typedef struct |
||
106 | { |
||
107 | uint32_t dev_endpoints; /*!< Device Endpoints number. |
||
108 | This parameter depends on the used USB core. |
||
109 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
||
110 | |||
111 | uint32_t Host_channels; /*!< Host Channels number. |
||
112 | This parameter Depends on the used USB core. |
||
113 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
||
114 | |||
115 | uint32_t speed; /*!< USB Core speed. |
||
116 | This parameter can be any value of @ref USB_Core_Speed_ */ |
||
117 | |||
118 | uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. |
||
119 | This parameter can be any value of @ref USB_EP0_MPS_ */ |
||
120 | |||
121 | uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */ |
||
122 | |||
123 | uint32_t low_power_enable; /*!< Enable or disable the low power mode. */ |
||
124 | |||
125 | uint32_t vbus_sensing_enable; /*!< Enable or disable the VBUS Sensing feature. */ |
||
126 | |||
127 | uint32_t use_external_vbus; /*!< Enable or disable the use of the external VBUS. */ |
||
128 | }USB_OTG_CfgTypeDef; |
||
129 | |||
130 | typedef struct |
||
131 | { |
||
132 | uint8_t num; /*!< Endpoint number |
||
133 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
||
134 | |||
135 | uint8_t is_in; /*!< Endpoint direction |
||
136 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
||
137 | |||
138 | uint8_t is_stall; /*!< Endpoint stall condition |
||
139 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
||
140 | |||
141 | uint8_t type; /*!< Endpoint type |
||
142 | This parameter can be any value of @ref USB_EP_Type_ */ |
||
143 | |||
144 | uint8_t data_pid_start; /*!< Initial data PID |
||
145 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
||
146 | |||
147 | uint8_t even_odd_frame; /*!< IFrame parity |
||
148 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
||
149 | |||
150 | uint16_t tx_fifo_num; /*!< Transmission FIFO number |
||
151 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
||
152 | |||
153 | uint32_t maxpacket; /*!< Endpoint Max packet size |
||
154 | This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ |
||
155 | |||
156 | uint8_t *xfer_buff; /*!< Pointer to transfer buffer */ |
||
157 | |||
158 | uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address */ |
||
159 | |||
160 | uint32_t xfer_len; /*!< Current transfer length */ |
||
161 | |||
162 | uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */ |
||
163 | }USB_OTG_EPTypeDef; |
||
164 | |||
165 | typedef struct |
||
166 | { |
||
167 | uint8_t dev_addr ; /*!< USB device address. |
||
168 | This parameter must be a number between Min_Data = 1 and Max_Data = 255 */ |
||
169 | |||
170 | uint8_t ch_num; /*!< Host channel number. |
||
171 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
||
172 | |||
173 | uint8_t ep_num; /*!< Endpoint number. |
||
174 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
||
175 | |||
176 | uint8_t ep_is_in; /*!< Endpoint direction |
||
177 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
||
178 | |||
179 | uint8_t speed; /*!< USB Host speed. |
||
180 | This parameter can be any value of @ref USB_Core_Speed_ */ |
||
181 | |||
182 | uint8_t do_ping; /*!< Enable or disable the use of the PING protocol for HS mode. */ |
||
183 | |||
184 | uint8_t process_ping; /*!< Execute the PING protocol for HS mode. */ |
||
185 | |||
186 | uint8_t ep_type; /*!< Endpoint Type. |
||
187 | This parameter can be any value of @ref USB_EP_Type_ */ |
||
188 | |||
189 | uint16_t max_packet; /*!< Endpoint Max packet size. |
||
190 | This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ |
||
191 | |||
192 | uint8_t data_pid; /*!< Initial data PID. |
||
193 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
||
194 | |||
195 | uint8_t *xfer_buff; /*!< Pointer to transfer buffer. */ |
||
196 | |||
197 | uint32_t xfer_len; /*!< Current transfer length. */ |
||
198 | |||
199 | uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer. */ |
||
200 | |||
201 | uint8_t toggle_in; /*!< IN transfer current toggle flag. |
||
202 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
||
203 | |||
204 | uint8_t toggle_out; /*!< OUT transfer current toggle flag |
||
205 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
||
206 | |||
207 | uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address. */ |
||
208 | |||
209 | uint32_t ErrCnt; /*!< Host channel error count.*/ |
||
210 | |||
211 | USB_OTG_URBStateTypeDef urb_state; /*!< URB state. |
||
212 | This parameter can be any value of @ref USB_OTG_URBStateTypeDef */ |
||
213 | |||
214 | USB_OTG_HCStateTypeDef state; /*!< Host Channel state. |
||
215 | This parameter can be any value of @ref USB_OTG_HCStateTypeDef */ |
||
216 | }USB_OTG_HCTypeDef; |
||
217 | #endif /* USB_OTG_FS */ |
||
218 | |||
219 | #if defined (USB) |
||
220 | /** |
||
221 | * @brief USB Initialization Structure definition |
||
222 | */ |
||
223 | typedef struct |
||
224 | { |
||
225 | uint32_t dev_endpoints; /*!< Device Endpoints number. |
||
226 | This parameter depends on the used USB core. |
||
227 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
||
228 | |||
229 | uint32_t speed; /*!< USB Core speed. |
||
230 | This parameter can be any value of @ref USB_Core_Speed */ |
||
231 | |||
232 | uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. |
||
233 | This parameter can be any value of @ref USB_EP0_MPS */ |
||
234 | |||
235 | uint32_t phy_itface; /*!< Select the used PHY interface. |
||
236 | This parameter can be any value of @ref USB_Core_PHY */ |
||
237 | |||
238 | uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */ |
||
239 | |||
240 | uint32_t low_power_enable; /*!< Enable or disable Low Power mode */ |
||
241 | |||
242 | uint32_t lpm_enable; /*!< Enable or disable Battery charging. */ |
||
243 | |||
244 | uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */ |
||
245 | } USB_CfgTypeDef; |
||
246 | |||
247 | typedef struct |
||
248 | { |
||
249 | uint8_t num; /*!< Endpoint number |
||
250 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
||
251 | |||
252 | uint8_t is_in; /*!< Endpoint direction |
||
253 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
||
254 | |||
255 | uint8_t is_stall; /*!< Endpoint stall condition |
||
256 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
||
257 | |||
258 | uint8_t type; /*!< Endpoint type |
||
259 | This parameter can be any value of @ref USB_EP_Type */ |
||
260 | |||
261 | uint16_t pmaadress; /*!< PMA Address |
||
262 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
||
263 | |||
264 | uint16_t pmaaddr0; /*!< PMA Address0 |
||
265 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
||
266 | |||
267 | uint16_t pmaaddr1; /*!< PMA Address1 |
||
268 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
||
269 | |||
270 | uint8_t doublebuffer; /*!< Double buffer enable |
||
271 | This parameter can be 0 or 1 */ |
||
272 | |||
273 | uint16_t tx_fifo_num; /*!< This parameter is not required by USB Device FS peripheral, it is used |
||
274 | only by USB OTG FS peripheral |
||
275 | This parameter is added to ensure compatibility across USB peripherals */ |
||
276 | |||
277 | uint32_t maxpacket; /*!< Endpoint Max packet size |
||
278 | This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ |
||
279 | |||
280 | uint8_t *xfer_buff; /*!< Pointer to transfer buffer */ |
||
281 | |||
282 | uint32_t xfer_len; /*!< Current transfer length */ |
||
283 | |||
284 | uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */ |
||
285 | |||
286 | } USB_EPTypeDef; |
||
287 | #endif /* USB */ |
||
288 | /** |
||
289 | * @} |
||
290 | */ |
||
291 | |||
292 | /* Exported constants --------------------------------------------------------*/ |
||
293 | /** @defgroup USB_LL_Exported_Constants USB Low Layer Exported Constants |
||
294 | * @{ |
||
295 | */ |
||
296 | #if defined (USB_OTG_FS) |
||
297 | /** @defgroup USB_LL_Core_Mode USB Low Layer Core Mode |
||
298 | * @{ |
||
299 | */ |
||
300 | #define USB_OTG_MODE_DEVICE 0 |
||
301 | #define USB_OTG_MODE_HOST 1 |
||
302 | #define USB_OTG_MODE_DRD 2 |
||
303 | /** |
||
304 | * @} |
||
305 | */ |
||
306 | |||
307 | /** @defgroup USB_LL_Core_Speed USB Low Layer Core Speed |
||
308 | * @{ |
||
309 | */ |
||
310 | #define USB_OTG_SPEED_LOW 2 |
||
311 | #define USB_OTG_SPEED_FULL 3 |
||
312 | |||
313 | /** |
||
314 | * @} |
||
315 | */ |
||
316 | |||
317 | /** @defgroup USB_LL_Core_PHY USB Low Layer Core PHY |
||
318 | * @{ |
||
319 | */ |
||
320 | #define USB_OTG_ULPI_PHY 1 |
||
321 | #define USB_OTG_EMBEDDED_PHY 2 |
||
322 | /** |
||
323 | * @} |
||
324 | */ |
||
325 | |||
326 | /** @defgroup USB_LL_Core_MPS USB Low Layer Core MPS |
||
327 | * @{ |
||
328 | */ |
||
329 | #define USB_OTG_FS_MAX_PACKET_SIZE 64 |
||
330 | #define USB_OTG_MAX_EP0_SIZE 64 |
||
331 | /** |
||
332 | * @} |
||
333 | */ |
||
334 | |||
335 | /** @defgroup USB_LL_Core_PHY_Frequency USB Low Layer Core PHY Frequency |
||
336 | * @{ |
||
337 | */ |
||
338 | #define DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ (1 << 1) |
||
339 | #define DSTS_ENUMSPD_LS_PHY_6MHZ (2 << 1) |
||
340 | #define DSTS_ENUMSPD_FS_PHY_48MHZ (3 << 1) |
||
341 | /** |
||
342 | * @} |
||
343 | */ |
||
344 | |||
345 | /** @defgroup USB_LL_CORE_Frame_Interval USB Low Layer Core Frame Interval |
||
346 | * @{ |
||
347 | */ |
||
348 | #define DCFG_FRAME_INTERVAL_80 0 |
||
349 | #define DCFG_FRAME_INTERVAL_85 1 |
||
350 | #define DCFG_FRAME_INTERVAL_90 2 |
||
351 | #define DCFG_FRAME_INTERVAL_95 3 |
||
352 | /** |
||
353 | * @} |
||
354 | */ |
||
355 | |||
356 | /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS |
||
357 | * @{ |
||
358 | */ |
||
359 | #define DEP0CTL_MPS_64 0 |
||
360 | #define DEP0CTL_MPS_32 1 |
||
361 | #define DEP0CTL_MPS_16 2 |
||
362 | #define DEP0CTL_MPS_8 3 |
||
363 | /** |
||
364 | * @} |
||
365 | */ |
||
366 | |||
367 | /** @defgroup USB_LL_EP_Speed USB Low Layer EP Speed |
||
368 | * @{ |
||
369 | */ |
||
370 | #define EP_SPEED_LOW 0 |
||
371 | #define EP_SPEED_FULL 1 |
||
372 | #define EP_SPEED_HIGH 2 |
||
373 | /** |
||
374 | * @} |
||
375 | */ |
||
376 | |||
377 | /** @defgroup USB_LL_EP_Type USB Low Layer EP Type |
||
378 | * @{ |
||
379 | */ |
||
380 | #define EP_TYPE_CTRL 0 |
||
381 | #define EP_TYPE_ISOC 1 |
||
382 | #define EP_TYPE_BULK 2 |
||
383 | #define EP_TYPE_INTR 3 |
||
384 | #define EP_TYPE_MSK 3 |
||
385 | /** |
||
386 | * @} |
||
387 | */ |
||
388 | |||
389 | /** @defgroup USB_LL_STS_Defines USB Low Layer STS Defines |
||
390 | * @{ |
||
391 | */ |
||
392 | #define STS_GOUT_NAK 1 |
||
393 | #define STS_DATA_UPDT 2 |
||
394 | #define STS_XFER_COMP 3 |
||
395 | #define STS_SETUP_COMP 4 |
||
396 | #define STS_SETUP_UPDT 6 |
||
397 | /** |
||
398 | * @} |
||
399 | */ |
||
400 | |||
401 | /** @defgroup USB_LL_HCFG_SPEED_Defines USB Low Layer HCFG Speed Defines |
||
402 | * @{ |
||
403 | */ |
||
404 | #define HCFG_30_60_MHZ 0 |
||
405 | #define HCFG_48_MHZ 1 |
||
406 | #define HCFG_6_MHZ 2 |
||
407 | /** |
||
408 | * @} |
||
409 | */ |
||
410 | |||
411 | /** @defgroup USB_LL_HPRT0_PRTSPD_SPEED_Defines USB Low Layer HPRT0 PRTSPD Speed Defines |
||
412 | * @{ |
||
413 | */ |
||
414 | #define HPRT0_PRTSPD_HIGH_SPEED 0 |
||
415 | #define HPRT0_PRTSPD_FULL_SPEED 1 |
||
416 | #define HPRT0_PRTSPD_LOW_SPEED 2 |
||
417 | /** |
||
418 | * @} |
||
419 | */ |
||
420 | |||
421 | #define HCCHAR_CTRL 0 |
||
422 | #define HCCHAR_ISOC 1 |
||
423 | #define HCCHAR_BULK 2 |
||
424 | #define HCCHAR_INTR 3 |
||
425 | |||
426 | #define HC_PID_DATA0 0 |
||
427 | #define HC_PID_DATA2 1 |
||
428 | #define HC_PID_DATA1 2 |
||
429 | #define HC_PID_SETUP 3 |
||
430 | |||
431 | #define GRXSTS_PKTSTS_IN 2 |
||
432 | #define GRXSTS_PKTSTS_IN_XFER_COMP 3 |
||
433 | #define GRXSTS_PKTSTS_DATA_TOGGLE_ERR 5 |
||
434 | #define GRXSTS_PKTSTS_CH_HALTED 7 |
||
435 | |||
436 | #define USBx_PCGCCTL *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_PCGCCTL_BASE) |
||
437 | #define USBx_HPRT0 *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_HOST_PORT_BASE) |
||
438 | |||
439 | #define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)((uint32_t )USBx + USB_OTG_DEVICE_BASE)) |
||
440 | #define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)((uint32_t)USBx + USB_OTG_IN_ENDPOINT_BASE + (i)*USB_OTG_EP_REG_SIZE)) |
||
441 | #define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)((uint32_t)USBx + USB_OTG_OUT_ENDPOINT_BASE + (i)*USB_OTG_EP_REG_SIZE)) |
||
442 | #define USBx_DFIFO(i) *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_FIFO_BASE + (i) * USB_OTG_FIFO_SIZE) |
||
443 | |||
444 | #define USBx_HOST ((USB_OTG_HostTypeDef *)((uint32_t )USBx + USB_OTG_HOST_BASE)) |
||
445 | #define USBx_HC(i) ((USB_OTG_HostChannelTypeDef *)((uint32_t)USBx + USB_OTG_HOST_CHANNEL_BASE + (i)*USB_OTG_HOST_CHANNEL_SIZE)) |
||
446 | #endif /* USB_OTG_FS */ |
||
447 | |||
448 | #if defined (USB) |
||
449 | /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS |
||
450 | * @{ |
||
451 | */ |
||
452 | #define DEP0CTL_MPS_64 0 |
||
453 | #define DEP0CTL_MPS_32 1 |
||
454 | #define DEP0CTL_MPS_16 2 |
||
455 | #define DEP0CTL_MPS_8 3 |
||
456 | /** |
||
457 | * @} |
||
458 | */ |
||
459 | |||
460 | /** @defgroup USB_LL_EP_Type USB Low Layer EP Type |
||
461 | * @{ |
||
462 | */ |
||
463 | #define EP_TYPE_CTRL 0 |
||
464 | #define EP_TYPE_ISOC 1 |
||
465 | #define EP_TYPE_BULK 2 |
||
466 | #define EP_TYPE_INTR 3 |
||
467 | #define EP_TYPE_MSK 3 |
||
468 | /** |
||
469 | * @} |
||
470 | */ |
||
471 | |||
472 | #define BTABLE_ADDRESS (0x000) |
||
473 | #endif /* USB */ |
||
474 | /** |
||
475 | * @} |
||
476 | */ |
||
477 | |||
478 | /* Exported macros -----------------------------------------------------------*/ |
||
479 | /** @defgroup USB_LL_Exported_Macros USB Low Layer Exported Macros |
||
480 | * @{ |
||
481 | */ |
||
482 | #if defined (USB_OTG_FS) |
||
483 | #define USB_MASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK &= ~(__INTERRUPT__)) |
||
484 | #define USB_UNMASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK |= (__INTERRUPT__)) |
||
485 | |||
486 | #define CLEAR_IN_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_INEP(__EPNUM__)->DIEPINT = (__INTERRUPT__)) |
||
487 | #define CLEAR_OUT_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_OUTEP(__EPNUM__)->DOEPINT = (__INTERRUPT__)) |
||
488 | #endif /* USB_OTG_FS */ |
||
489 | /** |
||
490 | * @} |
||
491 | */ |
||
492 | |||
493 | /* Exported functions --------------------------------------------------------*/ |
||
494 | /** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions |
||
495 | * @{ |
||
496 | */ |
||
497 | /** @addtogroup USB_LL_Exported_Functions_Group1 Peripheral Control functions |
||
498 | * @{ |
||
499 | */ |
||
500 | #if defined (USB_OTG_FS) |
||
501 | HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef Init); |
||
502 | HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef Init); |
||
503 | HAL_StatusTypeDef USB_EnableGlobalInt(USB_OTG_GlobalTypeDef *USBx); |
||
504 | HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx); |
||
505 | HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx , USB_ModeTypeDef mode); |
||
506 | HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx , uint8_t speed); |
||
507 | HAL_StatusTypeDef USB_FlushRxFifo (USB_OTG_GlobalTypeDef *USBx); |
||
508 | HAL_StatusTypeDef USB_FlushTxFifo (USB_OTG_GlobalTypeDef *USBx, uint32_t num ); |
||
509 | HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
||
510 | HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); |
||
511 | HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep); |
||
512 | HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep); |
||
513 | HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len); |
||
514 | void * USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len); |
||
515 | HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep); |
||
516 | HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep); |
||
517 | HAL_StatusTypeDef USB_SetDevAddress (USB_OTG_GlobalTypeDef *USBx, uint8_t address); |
||
518 | HAL_StatusTypeDef USB_DevConnect (USB_OTG_GlobalTypeDef *USBx); |
||
519 | HAL_StatusTypeDef USB_DevDisconnect (USB_OTG_GlobalTypeDef *USBx); |
||
520 | HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx); |
||
521 | HAL_StatusTypeDef USB_ActivateSetup (USB_OTG_GlobalTypeDef *USBx); |
||
522 | HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t *psetup); |
||
523 | uint8_t USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx); |
||
524 | uint32_t USB_GetMode(USB_OTG_GlobalTypeDef *USBx); |
||
525 | uint32_t USB_ReadInterrupts (USB_OTG_GlobalTypeDef *USBx); |
||
526 | uint32_t USB_ReadDevAllOutEpInterrupt (USB_OTG_GlobalTypeDef *USBx); |
||
527 | uint32_t USB_ReadDevOutEPInterrupt (USB_OTG_GlobalTypeDef *USBx , uint8_t epnum); |
||
528 | uint32_t USB_ReadDevAllInEpInterrupt (USB_OTG_GlobalTypeDef *USBx); |
||
529 | uint32_t USB_ReadDevInEPInterrupt (USB_OTG_GlobalTypeDef *USBx , uint8_t epnum); |
||
530 | void USB_ClearInterrupts (USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt); |
||
531 | |||
532 | HAL_StatusTypeDef USB_HostInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg); |
||
533 | HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx , uint8_t freq); |
||
534 | HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx); |
||
535 | HAL_StatusTypeDef USB_DriveVbus (USB_OTG_GlobalTypeDef *USBx, uint8_t state); |
||
536 | uint32_t USB_GetHostSpeed (USB_OTG_GlobalTypeDef *USBx); |
||
537 | uint32_t USB_GetCurrentFrame (USB_OTG_GlobalTypeDef *USBx); |
||
538 | HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx, |
||
539 | uint8_t ch_num, |
||
540 | uint8_t epnum, |
||
541 | uint8_t dev_address, |
||
542 | uint8_t speed, |
||
543 | uint8_t ep_type, |
||
544 | uint16_t mps); |
||
545 | HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_HCTypeDef *hc); |
||
546 | uint32_t USB_HC_ReadInterrupt (USB_OTG_GlobalTypeDef *USBx); |
||
547 | HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx , uint8_t hc_num); |
||
548 | HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx , uint8_t ch_num); |
||
549 | HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx); |
||
550 | HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx); |
||
551 | HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx); |
||
552 | #endif /* USB_OTG_FS */ |
||
553 | |||
554 | #if defined (USB) |
||
555 | HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef Init); |
||
556 | HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef Init); |
||
557 | HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx); |
||
558 | HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx); |
||
559 | HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx , USB_ModeTypeDef mode); |
||
560 | HAL_StatusTypeDef USB_SetDevSpeed(USB_TypeDef *USBx , uint8_t speed); |
||
561 | HAL_StatusTypeDef USB_FlushRxFifo (USB_TypeDef *USBx); |
||
562 | HAL_StatusTypeDef USB_FlushTxFifo (USB_TypeDef *USBx, uint32_t num ); |
||
563 | HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
||
564 | HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); |
||
565 | HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx , USB_EPTypeDef *ep); |
||
566 | HAL_StatusTypeDef USB_WritePacket(USB_TypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len); |
||
567 | void * USB_ReadPacket(USB_TypeDef *USBx, uint8_t *dest, uint16_t len); |
||
568 | HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx , USB_EPTypeDef *ep); |
||
569 | HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx , USB_EPTypeDef *ep); |
||
570 | HAL_StatusTypeDef USB_SetDevAddress (USB_TypeDef *USBx, uint8_t address); |
||
571 | HAL_StatusTypeDef USB_DevConnect (USB_TypeDef *USBx); |
||
572 | HAL_StatusTypeDef USB_DevDisconnect (USB_TypeDef *USBx); |
||
573 | HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx); |
||
574 | HAL_StatusTypeDef USB_EP0_OutStart(USB_TypeDef *USBx, uint8_t *psetup); |
||
575 | uint32_t USB_ReadInterrupts (USB_TypeDef *USBx); |
||
576 | uint32_t USB_ReadDevAllOutEpInterrupt (USB_TypeDef *USBx); |
||
577 | uint32_t USB_ReadDevOutEPInterrupt (USB_TypeDef *USBx , uint8_t epnum); |
||
578 | uint32_t USB_ReadDevAllInEpInterrupt (USB_TypeDef *USBx); |
||
579 | uint32_t USB_ReadDevInEPInterrupt (USB_TypeDef *USBx , uint8_t epnum); |
||
580 | void USB_ClearInterrupts (USB_TypeDef *USBx, uint32_t interrupt); |
||
581 | |||
582 | HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx); |
||
583 | HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx); |
||
584 | void USB_WritePMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes); |
||
585 | void USB_ReadPMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes); |
||
586 | #endif /* USB */ |
||
587 | /** |
||
588 | * @} |
||
589 | */ |
||
590 | /** |
||
591 | * @} |
||
592 | */ |
||
593 | |||
594 | /** |
||
595 | * @} |
||
596 | */ |
||
597 | |||
598 | /** |
||
599 | * @} |
||
600 | */ |
||
601 | |||
602 | #endif /* STM32F102x6 || STM32F102xB || */ |
||
603 | /* STM32F103x6 || STM32F103xB || */ |
||
604 | /* STM32F103xE || STM32F103xG || */ |
||
605 | /* STM32F105xC || STM32F107xC */ |
||
606 | |||
607 | #ifdef __cplusplus |
||
608 | } |
||
609 | #endif |
||
610 | |||
611 | |||
612 | #endif /* __STM32F1xx_LL_USB_H */ |
||
613 | |||
614 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |