Endpoint 0 Service Functions

group group_usbfs_dev_hal_functions_ep0_service

The Endpoint 0 Service functions provide an API to establish communication with the USB Host using control endpoint 0.

Functions

void Cy_USBFS_Dev_Drv_Ep0GetSetup(USBFS_Type const *base, uint8_t *buffer, cy_stc_usbfs_dev_drv_context_t const *context)

Reads the setup packed from the Endpoint 0 hardware buffer.

Parameters
  • base: The pointer to the USBFS instance.

  • buffer: The pointer to the buffer for data read from the Endpoint 0.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during the USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.

uint32_t Cy_USBFS_Dev_Drv_Ep0Write(USBFS_Type *base, uint8_t const *buffer, uint32_t size, cy_stc_usbfs_dev_drv_context_t *context)

Writes data into Endpoint 0 hardware buffer and returns how many bytes were written.

Return

The number of bytes that were written.

Parameters
  • base: The pointer to the USBFS instance.

  • buffer: The pointer to the buffer containing data bytes to write. To switch a transfer from the data stage to status, pass NULL as a pointer.

  • size: The number of bytes to write. Setting the size to zero sends to the bus zero-length data packet.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during the USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.

void Cy_USBFS_Dev_Drv_Ep0Read(USBFS_Type *base, uint8_t *buffer, uint32_t size, cy_stc_usbfs_dev_drv_context_t *context)

Start receiving a packet into the Endpoint 0 hardware buffer.

Parameters
  • base: The pointer to the USBFS instance.

  • buffer: The pointer to buffer that stores data that was read.

  • size: The number of bytes to read. Reading zero bytes switch control transfer to status stage.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during the USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.

uint32_t Cy_USBFS_Dev_Drv_Ep0ReadResult(USBFS_Type const *base, cy_stc_usbfs_dev_drv_context_t *context)

Reads data from the Endpoint 0 hardware and returns the number of read bytes.

Return

The number of read bytes.

Parameters
  • base: The pointer to the USBFS instance.

  • context: The pointer to the context structure cy_stc_usbfs_dev_drv_context_t allocated by the user. The structure is used during the USBFS Device operation for internal configuration and data retention. The user must not modify anything in this structure.

__STATIC_INLINE void Cy_USBFS_Dev_Drv_Ep0Stall (USBFS_Type *base)

Stalls endpoint 0.

Parameters
  • base: The pointer to the USBFS instance.

__STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetEp0MaxPacket (USBFS_Type const *base)

Returns the endpoint 0 maximum packet size that can be for read or write from the endpoint 0 buffer.

Return

The endpoint 0 maximum packet size (endpoint 0 has a dedicated hardware buffer).

Parameters
  • base: The pointer to the USBFS instance.