| M480 BSP V3.05.001 The Board Support Package for M480 Series

Macros | Typedefs | Functions
HSUSBD Exported Functions
Standard Driver » HSUSBD Driver

## Macros
#define | HSUSBD_ENABLE_USB()
#define | HSUSBD_DISABLE_USB()
#define | HSUSBD_ENABLE_PHY()
#define | HSUSBD_DISABLE_PHY()
#define | HSUSBD_SET_SE0()
#define | HSUSBD_CLR_SE0()
#define | HSUSBD_SET_ADDR(addr)
#define | HSUSBD_GET_ADDR()
#define | HSUSBD_ENABLE_USB_INT(intr)
#define | HSUSBD_ENABLE_BUS_INT(intr)
#define | HSUSBD_GET_BUS_INT_FLAG()
#define | HSUSBD_CLR_BUS_INT_FLAG(flag)
#define | HSUSBD_ENABLE_CEP_INT(intr)
#define | HSUSBD_CLR_CEP_INT_FLAG(flag)
#define | HSUSBD_SET_CEP_STATE(flag)
#define | HSUSBD_START_CEP_IN(size)
#define | HSUSBD_SET_MAX_PAYLOAD(ep, size)
#define | HSUSBD_ENABLE_EP_INT(ep, intr)
#define | HSUSBD_GET_EP_INT_FLAG(ep)
#define | HSUSBD_CLR_EP_INT_FLAG(ep, flag)
#define | HSUSBD_SET_DMA_LEN(len)
#define | HSUSBD_SET_DMA_ADDR(addr)
#define | HSUSBD_SET_DMA_READ(epnum)
#define | HSUSBD_SET_DMA_WRITE(epnum)
#define | HSUSBD_ENABLE_DMA()
#define | HSUSBD_IS_ATTACHED()

## Typedefs
typedef void(* | HSUSBD_VENDOR_REQ) (void)
typedef void(* | HSUSBD_CLASS_REQ) (void)
typedef void(* | HSUSBD_SET_INTERFACE_REQ) (uint32_t u32AltInterface)

## Functions
__STATIC_INLINE void | HSUSBD_MemCopy (uint8_t u8Dst[], uint8_t u8Src[], uint32_t u32Size)
| HSUSBD_memcpy, Copy bytes hardware limitation. More...
__STATIC_INLINE void | HSUSBD_ResetDMA (void)
| HSUSBD_ResetDMA. More...
__STATIC_INLINE void | HSUSBD_SetEpBufAddr (uint32_t u32Ep, uint32_t u32Base, uint32_t u32Len)
| HSUSBD_SetEpBufAddr, Set Endpoint buffer address. More...
__STATIC_INLINE void | HSUSBD_ConfigEp (uint32_t u32Ep, uint32_t u32EpNum, uint32_t u32EpType, uint32_t u32EpDir)
| HSUSBD_ConfigEp, Config Endpoint. More...
__STATIC_INLINE void | HSUSBD_SetEpStall (uint32_t u32Ep)
| Set USB endpoint stall state. More...
__STATIC_INLINE void | HSUSBD_SetStall (uint32_t u32EpNum)
| Set USB endpoint stall state. More...
__STATIC_INLINE void | HSUSBD_ClearEpStall (uint32_t u32Ep)
| Clear USB endpoint stall state. More...
__STATIC_INLINE void | HSUSBD_ClearStall (uint32_t u32EpNum)
| Clear USB endpoint stall state. More...
__STATIC_INLINE uint32_t | HSUSBD_GetEpStall (uint32_t u32Ep)
| Get USB endpoint stall state. More...
__STATIC_INLINE uint32_t | HSUSBD_GetStall (uint32_t u32EpNum)
| Get USB endpoint stall state. More...
void | HSUSBD_Open (S_HSUSBD_INFO_T *param, HSUSBD_CLASS_REQ pfnClassReq, HSUSBD_SET_INTERFACE_REQ pfnSetInterface)
| HSUSBD Initial. More...
void | HSUSBD_Start (void)
| HSUSBD Start. More...
void | HSUSBD_ProcessSetupPacket (void)
| Process Setup Packet. More...
void | HSUSBD_StandardRequest (void)
| Process USB standard request. More...
void | HSUSBD_UpdateDeviceState (void)
| Update Device State. More...
void | HSUSBD_PrepareCtrlIn (uint8_t pu8Buf[], uint32_t u32Size)
| Prepare Control IN transaction. More...
void | HSUSBD_CtrlIn (void)
| Start Control IN transfer. More...
void | HSUSBD_CtrlOut (uint8_t pu8Buf[], uint32_t u32Size)
| Start Control OUT transaction. More...
void | HSUSBD_SwReset (void)
| Clear all software flags. More...
void | HSUSBD_SetVendorRequest (HSUSBD_VENDOR_REQ pfnVendorReq)
| HSUSBD Set Vendor Request. More...
int | HSUSBD_GetDescriptor (void)
| Get Descriptor request. More...

## Detailed Description

HIDDEN_SYMBOLS

## Macro Definition Documentation

## ◆ HSUSBD_CLR_BUS_INT_FLAG

#define HSUSBD_CLR_BUS_INT_FLAG | ( |  | flag | ) |

Clear Bus interrupt flag

Definition at line 144 of file hsusbd.h.

## ◆ HSUSBD_CLR_CEP_INT_FLAG

#define HSUSBD_CLR_CEP_INT_FLAG | ( |  | flag | ) |

Clear CEP interrupt flag

Definition at line 146 of file hsusbd.h.

## ◆ HSUSBD_CLR_EP_INT_FLAG

#define HSUSBD_CLR_EP_INT_FLAG | ( |  | ep,
|  |  | flag
| ) |  |

Clear EPx interrupt flag

Definition at line 152 of file hsusbd.h.

## ◆ HSUSBD_CLR_SE0

#define HSUSBD_CLR_SE0 | ( |  | ) |

Disable SE0

Definition at line 138 of file hsusbd.h.

## ◆ HSUSBD_DISABLE_PHY

#define HSUSBD_DISABLE_PHY | ( |  | ) |

Disable PHY

Definition at line 136 of file hsusbd.h.

## ◆ HSUSBD_DISABLE_USB

#define HSUSBD_DISABLE_USB | ( |  | ) |

Disable USB

Definition at line 134 of file hsusbd.h.

## ◆ HSUSBD_ENABLE_BUS_INT

#define HSUSBD_ENABLE_BUS_INT | ( |  | intr | ) |

Enable BUS Interrupt

Definition at line 142 of file hsusbd.h.

## ◆ HSUSBD_ENABLE_CEP_INT

#define HSUSBD_ENABLE_CEP_INT | ( |  | intr | ) |

Enable CEP Interrupt

Definition at line 145 of file hsusbd.h.

## ◆ HSUSBD_ENABLE_DMA

#define HSUSBD_ENABLE_DMA | ( |  | ) |

Enable DMA transfer

Definition at line 157 of file hsusbd.h.

## ◆ HSUSBD_ENABLE_EP_INT

#define HSUSBD_ENABLE_EP_INT | ( |  | ep,
|  |  | intr
| ) |  |

Enable EPx Interrupt

Definition at line 150 of file hsusbd.h.

## ◆ HSUSBD_ENABLE_PHY

#define HSUSBD_ENABLE_PHY | ( |  | ) |

Enable PHY

Definition at line 135 of file hsusbd.h.

## ◆ HSUSBD_ENABLE_USB

#define HSUSBD_ENABLE_USB | ( |  | ) |

Enable USB

Definition at line 133 of file hsusbd.h.

## ◆ HSUSBD_ENABLE_USB_INT

#define HSUSBD_ENABLE_USB_INT | ( |  | intr | ) |

Enable USB Interrupt

Definition at line 141 of file hsusbd.h.

## ◆ HSUSBD_GET_ADDR

#define HSUSBD_GET_ADDR | ( |  | ) |

Get USB address

Definition at line 140 of file hsusbd.h.

## ◆ HSUSBD_GET_BUS_INT_FLAG

#define HSUSBD_GET_BUS_INT_FLAG | ( |  | ) |

Get Bus interrupt flag

Definition at line 143 of file hsusbd.h.

## ◆ HSUSBD_GET_EP_INT_FLAG

#define HSUSBD_GET_EP_INT_FLAG | ( |  | ep | ) |

Get EPx interrupt flag

Definition at line 151 of file hsusbd.h.

## ◆ HSUSBD_IS_ATTACHED

#define HSUSBD_IS_ATTACHED | ( |  | ) |

Check cable connect state

Definition at line 158 of file hsusbd.h.

## ◆ HSUSBD_SET_ADDR

#define HSUSBD_SET_ADDR | ( |  | addr | ) |

Set USB address

Definition at line 139 of file hsusbd.h.

## ◆ HSUSBD_SET_CEP_STATE

#define HSUSBD_SET_CEP_STATE | ( |  | flag | ) |

Set CEP state

Definition at line 147 of file hsusbd.h.

## ◆ HSUSBD_SET_DMA_ADDR

#define HSUSBD_SET_DMA_ADDR | ( |  | addr | ) |

Set DMA transfer address

Definition at line 154 of file hsusbd.h.

## ◆ HSUSBD_SET_DMA_LEN

#define HSUSBD_SET_DMA_LEN | ( |  | len | ) |

Set DMA transfer length

Definition at line 153 of file hsusbd.h.

## ◆ HSUSBD_SET_DMA_READ

#define HSUSBD_SET_DMA_READ | ( |  | epnum | ) |

Set DMA transfer type to read

Definition at line 155 of file hsusbd.h.

## ◆ HSUSBD_SET_DMA_WRITE

#define HSUSBD_SET_DMA_WRITE | ( |  | epnum | ) |

Set DMA transfer type to write

Definition at line 156 of file hsusbd.h.

## ◆ HSUSBD_SET_MAX_PAYLOAD

#define HSUSBD_SET_MAX_PAYLOAD | ( |  | ep,
|  |  | size
| ) |  |

Set EPx Maximum Packet Size

Definition at line 149 of file hsusbd.h.

## ◆ HSUSBD_SET_SE0

#define HSUSBD_SET_SE0 | ( |  | ) |

Enable SE0, Force USB PHY Transceiver to Drive SE0

Definition at line 137 of file hsusbd.h.

## ◆ HSUSBD_START_CEP_IN

#define HSUSBD_START_CEP_IN | ( |  | size | ) |

Start CEP IN Transfer

Definition at line 148 of file hsusbd.h.

## Typedef Documentation

## ◆ HSUSBD_CLASS_REQ

typedef void(* HSUSBD_CLASS_REQ) (void)

USB Class request callback function

Definition at line 354 of file hsusbd.h.

## ◆ HSUSBD_SET_INTERFACE_REQ

typedef void(* HSUSBD_SET_INTERFACE_REQ) (uint32_t u32AltInterface)

USB Standard request "Set Interface" callback function

Definition at line 355 of file hsusbd.h.

## ◆ HSUSBD_VENDOR_REQ

typedef void(* HSUSBD_VENDOR_REQ) (void)

USB Vendor request callback function

Definition at line 353 of file hsusbd.h.

## Function Documentation

## ◆ HSUSBD_ClearEpStall()

__STATIC_INLINE void HSUSBD_ClearEpStall | ( | uint32_t | u32Ep | ) |

Clear USB endpoint stall state.

Parameters

  [in] | u32Ep | The USB endpoint ID.

Returns
  None

Clear USB endpoint stall state for the specified endpoint ID. Endpoint will respond ACK/NAK token.

Definition at line 288 of file hsusbd.h.

## ◆ HSUSBD_ClearStall()

__STATIC_INLINE void HSUSBD_ClearStall | ( | uint32_t | u32EpNum | ) |

Clear USB endpoint stall state.

Parameters

  [in] | u32EpNum | USB endpoint

Returns
  None

Clear USB endpoint stall state, endpoint will return ACK/NAK token.

Definition at line 301 of file hsusbd.h.

## ◆ HSUSBD_ConfigEp()

__STATIC_INLINE void HSUSBD_ConfigEp | ( | uint32_t | u32Ep,
|  | uint32_t | u32EpNum,
|  | uint32_t | u32EpType,
|  | uint32_t | u32EpDir
| ) |  |

HSUSBD_ConfigEp, Config Endpoint.

Parameters

  [in] | u32Ep | USB endpoint
  [in] | u32EpNum | Endpoint number
  [in] | u32EpType | Endpoint type
  [in] | u32EpDir | Endpoint direction

Return values

  None. |

Definition at line 218 of file hsusbd.h.

## ◆ HSUSBD_CtrlIn()

void HSUSBD_CtrlIn | ( | void |  | ) |

Start Control IN transfer.

Parameters

  [in] | None |

Returns
  None

This function is used to start Control IN

Definition at line 618 of file hsusbd.c.

## ◆ HSUSBD_CtrlOut()

void HSUSBD_CtrlOut | ( | uint8_t | pu8Buf[],
|  | uint32_t | u32Size
| ) |  |

Start Control OUT transaction.

Parameters

  [in] | pu8Buf | Control OUT data pointer
  [in] | u32Size | OUT transfer size

Returns
  None

This function is used to start Control OUT transfer

Definition at line 666 of file hsusbd.c.

## ◆ HSUSBD_GetDescriptor()

int HSUSBD_GetDescriptor | ( | void |  | ) |

Get Descriptor request.

Parameters

  [in] | None |

Returns
  None

This function is used to process GetDescriptor request.

Definition at line 171 of file hsusbd.c.

## ◆ HSUSBD_GetEpStall()

__STATIC_INLINE uint32_t HSUSBD_GetEpStall | ( | uint32_t | u32Ep | ) |

Get USB endpoint stall state.

Parameters

  [in] | u32Ep | The USB endpoint ID.

Return values

  0 | USB endpoint is not stalled.
  Others | USB endpoint is stalled.

Get USB endpoint stall state of the specified endpoint ID.

Definition at line 321 of file hsusbd.h.

## ◆ HSUSBD_GetStall()

__STATIC_INLINE uint32_t HSUSBD_GetStall | ( | uint32_t | u32EpNum | ) |

Get USB endpoint stall state.

Parameters

  [in] | u32EpNum | USB endpoint

Return values

  0 | USB endpoint is not stalled.
  non-0 | USB endpoint is stalled.

Get USB endpoint stall state.

Definition at line 335 of file hsusbd.h.

## ◆ HSUSBD_MemCopy()

__STATIC_INLINE void HSUSBD_MemCopy | ( | uint8_t | u8Dst[],
|  | uint8_t | u8Src[],
|  | uint32_t | u32Size
| ) |  |

HSUSBD_memcpy, Copy bytes hardware limitation.

Parameters

  [in] | u8Dst | Destination pointer.
  [in] | u8Src | Source pointer.
  [in] | u32Size | Copy size.

Return values

  None. |

Definition at line 167 of file hsusbd.h.

## ◆ HSUSBD_Open()

void HSUSBD_Open | ( | S_HSUSBD_INFO_T * | param,
|  | HSUSBD_CLASS_REQ | pfnClassReq,
|  | HSUSBD_SET_INTERFACE_REQ | pfnSetInterface
| ) |  |

HSUSBD Initial.

HIDDEN_SYMBOLS

Parameters

  [in] | param | Descriptor
  [in] | pfnClassReq | Class Request Callback Function
  [in] | pfnSetInterface | SetInterface Request Callback Function

Returns
  None

This function is used to initial HSUSBD.

Definition at line 68 of file hsusbd.c.

## ◆ HSUSBD_PrepareCtrlIn()

void HSUSBD_PrepareCtrlIn | ( | uint8_t | pu8Buf[],
|  | uint32_t | u32Size
| ) |  |

Prepare Control IN transaction.

Parameters

  [in] | pu8Buf | Control IN data pointer
  [in] | u32Size | IN transfer size

Returns
  None

This function is used to prepare Control IN transfer

Definition at line 601 of file hsusbd.c.

## ◆ HSUSBD_ProcessSetupPacket()

void HSUSBD_ProcessSetupPacket | ( | void |  | ) |

Process Setup Packet.

Parameters

  [in] | None |

Returns
  None

This function is used to process Setup packet.

Definition at line 120 of file hsusbd.c.

## ◆ HSUSBD_ResetDMA()

__STATIC_INLINE void HSUSBD_ResetDMA | ( | void |  | ) |

HSUSBD_ResetDMA.

Parameters

  None |

Return values

  None. |

Definition at line 183 of file hsusbd.h.

## ◆ HSUSBD_SetEpBufAddr()

__STATIC_INLINE void HSUSBD_SetEpBufAddr | ( | uint32_t | u32Ep,
|  | uint32_t | u32Base,
|  | uint32_t | u32Len
| ) |  |

HSUSBD_SetEpBufAddr, Set Endpoint buffer address.

Parameters

  [in] | u32Ep | Endpoint Number
  [in] | u32Base | Buffer Start Address
  [in] | u32Len | Buffer length

Return values

  None. |

Definition at line 196 of file hsusbd.h.

## ◆ HSUSBD_SetEpStall()

__STATIC_INLINE void HSUSBD_SetEpStall | ( | uint32_t | u32Ep | ) |

Set USB endpoint stall state.

Parameters

  [in] | u32Ep | The USB endpoint ID.

Returns
  None

Set USB endpoint stall state for the specified endpoint ID. Endpoint will respond STALL token automatically.

Definition at line 242 of file hsusbd.h.

## ◆ HSUSBD_SetStall()

__STATIC_INLINE void HSUSBD_SetStall | ( | uint32_t | u32EpNum | ) |

Set USB endpoint stall state.

Parameters

  [in] | u32EpNum | USB endpoint

Returns
  None

Set USB endpoint stall state, endpoint will return STALL token.

Definition at line 262 of file hsusbd.h.

## ◆ HSUSBD_SetVendorRequest()

void HSUSBD_SetVendorRequest | ( | HSUSBD_VENDOR_REQ | pfnVendorReq | ) |

HSUSBD Set Vendor Request.

Parameters

  [in] | pfnVendorReq | Vendor Request Callback Function

Returns
  None

This function is used to set HSUSBD vendor request callback function

Definition at line 713 of file hsusbd.c.

## ◆ HSUSBD_StandardRequest()

void HSUSBD_StandardRequest | ( | void |  | ) |

Process USB standard request.

Parameters

  [in] | None |

Returns
  None

This function is used to process USB Standard Request.

Definition at line 333 of file hsusbd.c.

## ◆ HSUSBD_Start()

void HSUSBD_Start | ( | void |  | ) |

HSUSBD Start.

Parameters

  [in] | None |

Returns
  None

This function is used to start transfer

Definition at line 106 of file hsusbd.c.

## ◆ HSUSBD_SwReset()

void HSUSBD_SwReset | ( | void |  | ) |

Clear all software flags.

Parameters

  [in] | None |

Returns
  None

This function is used to clear all software control flag

Definition at line 692 of file hsusbd.c.

## ◆ HSUSBD_UpdateDeviceState()

void HSUSBD_UpdateDeviceState | ( | void |  | ) |

Update Device State.

Parameters

  [in] | None |

Returns
  None

This function is used to update Device state when Setup packet completeHIDDEN_SYMBOLS

Definition at line 516 of file hsusbd.c.