Subversion Repositories AFRtranscoder

Rev

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