bf0_hal_pcd.h
Header file of PCD HAL module.
- Author
Sifli software development team
- Attention
Defines
-
EP_TYPE_CTRL
-
EP_TYPE_BULKOUT
-
EP_TYPE_BULKIN
-
PCD_SPEED_HIGH
-
PCD_SPEED_FULL
-
PCD_EP0_MPSIZE
-
PCD_PHY_EMBEDDED
-
USB_USBCFG_AVALID
-
USB_USBCFG_AVALID_DR
-
USB_ENABLE_PHY(hpcd)
-
USB_DISABLE_DOUBLE_BUFFER(hpcd)
-
PCD_EP_TYPE_CTRL
-
PCD_EP_TYPE_ISOC
-
PCD_EP_TYPE_BULK
-
PCD_EP_TYPE_INTR
-
PCD_ENDP0
-
PCD_ENDP1
-
PCD_ENDP2
-
PCD_ENDP3
-
PCD_ENDP4
-
PCD_ENDP5
-
PCD_ENDP6
-
PCD_ENDP7
Typedefs
-
typedef USBC_X_Typedef PCD_TypeDef
Enums
-
enum PCD_StateTypeDef
PCD State structure definition.
Values:
-
enumerator HAL_PCD_STATE_RESET
-
enumerator HAL_PCD_STATE_READY
-
enumerator HAL_PCD_STATE_ERROR
-
enumerator HAL_PCD_STATE_BUSY
-
enumerator HAL_PCD_STATE_TIMEOUT
-
enumerator HAL_PCD_STATE_RESET
-
enum PCD_PhyStateTypeDef
PCD PHY State.
Values:
-
enumerator OTG_STATE_A_SUSPEND
-
enumerator OTG_STATE_A_HOST
-
enumerator OTG_STATE_A_WAIT_BCON
-
enumerator OTG_STATE_A_WAIT_VFALL
-
enumerator OTG_STATE_A_WAIT_VRISE
-
enumerator OTG_STATE_B_HOST
-
enumerator OTG_STATE_B_PERIPHERALS
-
enumerator OTG_STATE_B_WAIT_ACON
-
enumerator OTG_STATE_B_IDLE
-
enumerator OTG_STATE_A_SUSPEND
-
enum PCD_EP0_StateTypeDef
PCD Endpont 0 State structure definition.
Values:
-
enumerator HAL_PCD_EP0_IDLE
Idle, waiting for setup
-
enumerator HAL_PCD_EP0_SETUP
Received setup
-
enumerator HAL_PCD_EP0_TX
IN data
-
enumerator HAL_PCD_EP0_RX
OUT data
-
enumerator HAL_PCD_EP0_STATUSIN
(After OUT data)
-
enumerator HAL_PCD_EP0_STATUSOUT
(After IN data)
-
enumerator HAL_PCD_EP0_ACKWAIT
After zlp, before statusin
-
enumerator HAL_PCD_EP0_IDLE
Functions
-
HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd)
Initializes the PCD according to the specified parameters in the PCD_InitTypeDef and create the associated handle.
- 参数:
hpcd – PCD handle
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_PCD_DeInit(PCD_HandleTypeDef *hpcd)
DeInitializes the PCD peripheral.
- 参数:
hpcd – PCD handle
- 返回值:
HAL – status
-
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
Initializes the PCD MSP.
- 参数:
hpcd – PCD handle
- 返回值:
None –
-
void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd)
DeInitializes PCD MSP.
- 参数:
hpcd – PCD handle
- 返回值:
None –
-
void HAL_PCD_Enable(uint8_t enable)
Enable/disable PCD.
- 参数:
enable – 1: enable, 0: disable
- 返回值:
None –
-
HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd)
Start the USB device.
- 参数:
hpcd – PCD handle
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd)
Stop the USB device.
- 参数:
hpcd – PCD handle
- 返回值:
HAL – status
-
void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd)
This function handles PCD interrupt request.
- 参数:
hpcd – PCD handle
- 返回值:
HAL – status
-
void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
Data out stage callbacks.
- 参数:
hpcd – PCD handle
epnum – endpoint number
- 返回值:
None –
-
void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
Data IN stage callbacks.
- 参数:
hpcd – PCD handle
epnum – endpoint number
- 返回值:
None –
-
void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
Setup stage callback.
- 参数:
hpcd – PCD handle
- 返回值:
None –
-
void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
USB Start Of Frame callbacks.
- 参数:
hpcd – PCD handle
- 返回值:
None –
-
void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
USB Reset callbacks.
- 参数:
hpcd – PCD handle
- 返回值:
None –
-
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
Suspend event callbacks.
- 参数:
hpcd – PCD handle
- 返回值:
None –
-
void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
Resume event callbacks.
- 参数:
hpcd – PCD handle
- 返回值:
None –
-
void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
Incomplete ISO OUT callbacks.
- 参数:
hpcd – PCD handle
epnum – endpoint number
- 返回值:
None –
-
void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
Incomplete ISO IN callbacks.
- 参数:
hpcd – PCD handle
epnum – endpoint number
- 返回值:
None –
-
void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
Connection event callbacks.
- 参数:
hpcd – PCD handle
- 返回值:
None –
-
void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
Disconnection event callbacks.
- 参数:
hpcd – PCD handle
- 返回值:
None –
-
HAL_StatusTypeDef HAL_PCD_SetAddress(PCD_HandleTypeDef *hpcd, uint8_t address)
Set the USB Device address.
- 参数:
hpcd – PCD handle
address – new device address
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_PCD_EP_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint16_t ep_mps, uint8_t ep_type)
Open and configure an endpoint.
- 参数:
hpcd – PCD handle
ep_addr – endpoint address
ep_mps – endpoint max packert size
ep_type – endpoint type
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_PCD_EP_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr)
Deactivate an endpoint.
- 参数:
hpcd – PCD handle
ep_addr – endpoint address
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_PCD_EP_Prepare_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len)
Prepare to receive an amount of data.
- 参数:
hpcd – PCD handle
ep_addr – endpoint address
pBuf – pointer to the reception buffer
len – amount of data to be received
- 返回值:
HAL – status
-
uint32_t HAL_PCD_EP_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf)
Receive an amount of data.
- 参数:
hpcd – PCD handle
ep_addr – endpoint address
pBuf – pointer to the reception buffer
- 返回值:
received – packet size.
-
HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len)
Send an amount of data.
- 参数:
hpcd – PCD handle
ep_addr – endpoint address
pBuf – pointer to the transmission buffer
len – amount of data to be sent
- 返回值:
HAL – status
-
uint16_t HAL_PCD_EP_GetRxCount(PCD_HandleTypeDef *hpcd, uint8_t ep_addr)
Get Received Data Size.
- 参数:
hpcd – PCD handle
ep_addr – endpoint address
- 返回值:
Data – Size
-
HAL_StatusTypeDef HAL_PCD_EP_SetStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr)
Set a STALL condition over an endpoint.
- 参数:
hpcd – PCD handle
ep_addr – endpoint address
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_PCD_EP_ClrStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr)
Clear a STALL condition over in an endpoint.
- 参数:
hpcd – PCD handle
ep_addr – endpoint address
- 返回值:
HAL – status
-
HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr)
Flush an endpoint.
- 参数:
hpcd – PCD handle
ep_addr – endpoint address
- 返回值:
HAL – status
-
PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd)
Return the PCD state.
- 参数:
hpcd – PCD handle
- 返回值:
HAL – state
-
HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr, void *dma_config)
-
HAL_StatusTypeDef HAL_PCD_TestMode(PCD_HandleTypeDef *hpcd, uint16_t tm, uint8_t *data, uint8_t len)
Set test mode.
- 参数:
hpcd – PCD handle
tm – test mode see USB 2.0 spec, section 9.4.9 wIndex
data – used in TEST_PACKET
len – length of data
- 返回值:
HAL – status
-
void HAL_PCD_Set_RxbuffControl(uint8_t ep_num, uint8_t flag)
-
void HAL_PCD_Set_RxscrACK(uint8_t epnum)
-
struct PCD_InitTypeDef
- #include <bf0_hal_pcd.h>
PCD Initialization Structure definition.
Public Members
-
uint32_t dev_endpoints
Device Endpoints number. This parameter depends on the used USB core. This parameter must be a number between Min_Data = 1 and Max_Data = 15
-
uint32_t speed
USB Core speed. This parameter can be any value of PCD Core Speed
-
uint32_t ep0_mps
Set the Endpoint 0 Max Packet size. This parameter can be any value of PCD EP0 Max Packet Size
-
uint32_t phy_itface
Select the used PHY interface. This parameter can be any value of PCD Core PHY
-
uint32_t Sof_enable
Enable or disable the output of the SOF signal. This parameter can be set to ENABLE or DISABLE
-
uint32_t low_power_enable
Enable or disable Low Power mode This parameter can be set to ENABLE or DISABLE
-
uint32_t lpm_enable
Enable or disable the Link Power Management . This parameter can be set to ENABLE or DISABLE
-
uint32_t battery_charging_enable
Enable or disable Battery charging. This parameter can be set to ENABLE or DISABLE
-
uint32_t dev_endpoints
-
struct PCD_EPTypeDef
Public Members
-
uint8_t num
Endpoint number This parameter must be a number between Min_Data = 1 and Max_Data = 15
-
uint8_t is_in
Endpoint direction This parameter must be a number between Min_Data = 0 and Max_Data = 1
-
uint8_t is_stall
Endpoint stall condition This parameter must be a number between Min_Data = 0 and Max_Data = 1
-
uint8_t type
Endpoint type This parameter can be any value of PCD EP Type
-
void *dma_cfg
-
uint32_t pmaadress
-
uint32_t maxpacket
Endpoint Max packet size This parameter must be a number between Min_Data = 0 and Max_Data = 64KB
-
uint8_t *xfer_buff
Pointer to transfer buffer
-
uint32_t xfer_len
Current transfer length
-
uint32_t xfer_count
Partial transfer length in case of multi packet transfer
-
uint8_t num
-
struct PCD_HandleTypeDef
- #include <bf0_hal_pcd.h>
PCD Handle Structure definition.
Public Members
-
PCD_TypeDef *Instance
Register base address
-
PCD_InitTypeDef Init
PCD required parameters
-
uint8_t USB_Address
USB Address
-
PCD_EPTypeDef IN_ep[8]
IN endpoint parameters
-
PCD_EPTypeDef OUT_ep[8]
OUT endpoint parameters
-
HAL_LockTypeDef Lock
PCD peripheral status
-
PCD_StateTypeDef State
PCD communication state
-
uint32_t Setup[12]
Setup packet buffer
-
void *pData
Pointer to upper stack Handler
-
PCD_EP0_StateTypeDef ep0_state
EP0 state
-
PCD_PhyStateTypeDef phy_state
PHY state
-
uint16_t ackpend
Pending ACK, EP0 only
-
PCD_TypeDef *Instance