MTB CAT1 Peripheral driver library
Data Endpoint Transfer Functions

General Description

The Data Endpoint Transfer functions provide an API to establish communication with the USB Host using data endpoint.

Functions

__STATIC_INLINE cy_en_usb_dev_ep_state_t Cy_USBFS_Dev_Drv_GetEndpointState (USBFS_Type const *base, uint32_t endpoint, cy_stc_usbfs_dev_drv_context_t const *context)
 Returns the state of the endpoint. More...
 
__STATIC_INLINE cy_en_usbfs_dev_drv_status_t Cy_USBFS_Dev_Drv_LoadInEndpoint (USBFS_Type *base, uint32_t endpoint, uint8_t const *buffer, uint32_t size, cy_stc_usbfs_dev_drv_context_t *context)
 Loads data into the IN endpoint buffer. More...
 
void Cy_USBFS_Dev_Drv_EnableOutEndpoint (USBFS_Type *base, uint32_t endpoint, cy_stc_usbfs_dev_drv_context_t *context)
 Enables the OUT data endpoint to be read by the Host. More...
 
__STATIC_INLINE cy_en_usbfs_dev_drv_status_t Cy_USBFS_Dev_Drv_ReadOutEndpoint (USBFS_Type *base, uint32_t endpoint, uint8_t *buffer, uint32_t size, uint32_t *actSize, cy_stc_usbfs_dev_drv_context_t *context)
 Reads data from the OUT endpoint buffer. More...
 
cy_en_usbfs_dev_drv_status_t Cy_USBFS_Dev_Drv_Abort (USBFS_Type *base, uint32_t endpoint, cy_stc_usbfs_dev_drv_context_t *context)
 Abort operation for data endpoint. More...
 
__STATIC_INLINE bool Cy_USBFS_Dev_Drv_GetEndpointAckState (USBFS_Type const *base, uint32_t endpoint)
 Returns whether the transaction completed with ACK for a certain endpoint. More...
 
__STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetEndpointCount (USBFS_Type const *base, uint32_t endpoint)
 Returns the number of data bytes in the transaction for a certain endpoint. More...
 
cy_en_usbfs_dev_drv_status_t Cy_USBFS_Dev_Drv_StallEndpoint (USBFS_Type *base, uint32_t endpoint, cy_stc_usbfs_dev_drv_context_t *context)
 Configures data endpoint to STALL any request intended for it. More...
 
cy_en_usbfs_dev_drv_status_t Cy_USBFS_Dev_Drv_UnStallEndpoint (USBFS_Type *base, uint32_t endpoint, cy_stc_usbfs_dev_drv_context_t *context)
 Release data endpoint STALL condition and clears data toggle bit. More...
 

Function Documentation

◆ Cy_USBFS_Dev_Drv_GetEndpointState()

__STATIC_INLINE cy_en_usb_dev_ep_state_t Cy_USBFS_Dev_Drv_GetEndpointState ( USBFS_Type const *  base,
uint32_t  endpoint,
cy_stc_usbfs_dev_drv_context_t const *  context 
)

Returns the state of the endpoint.

Parameters
baseThe pointer to the USBFS instance.
endpointThe data endpoint number.
contextThe 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.
Returns
Data endpoint state cy_en_usb_dev_ep_state_t.

◆ Cy_USBFS_Dev_Drv_LoadInEndpoint()

__STATIC_INLINE cy_en_usbfs_dev_drv_status_t Cy_USBFS_Dev_Drv_LoadInEndpoint ( USBFS_Type *  base,
uint32_t  endpoint,
uint8_t const *  buffer,
uint32_t  size,
cy_stc_usbfs_dev_drv_context_t context 
)

Loads data into the IN endpoint buffer.

After data loads, the endpoint is ready to be read by the host.

Parameters
baseThe pointer to the USBFS instance.
endpointThe IN data endpoint number.
bufferThe pointer to the buffer containing data bytes to load.
sizeThe number of bytes to load into the endpoint. This value must be less than or equal to endpoint maximum packet size.
contextThe 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.
Returns
The status code of the function execution cy_en_usbfs_dev_drv_status_t.

◆ Cy_USBFS_Dev_Drv_EnableOutEndpoint()

void Cy_USBFS_Dev_Drv_EnableOutEndpoint ( USBFS_Type *  base,
uint32_t  endpoint,
cy_stc_usbfs_dev_drv_context_t context 
)

Enables the OUT data endpoint to be read by the Host.

Parameters
baseThe pointer to the USBFS instance.
endpointThe OUT data endpoint number.
contextThe 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.
Returns
Status code of the function execution cy_en_usbfs_dev_drv_status_t.
Note
The OUT endpoints are not enabled by default. The endpoints must be enabled before calling Cy_USBFS_Dev_Drv_ReadOutEndpoint to read data from an endpoint.

◆ Cy_USBFS_Dev_Drv_ReadOutEndpoint()

__STATIC_INLINE cy_en_usbfs_dev_drv_status_t Cy_USBFS_Dev_Drv_ReadOutEndpoint ( USBFS_Type *  base,
uint32_t  endpoint,
uint8_t *  buffer,
uint32_t  size,
uint32_t *  actSize,
cy_stc_usbfs_dev_drv_context_t context 
)

Reads data from the OUT endpoint buffer.

Before executing a next read, the Cy_USBFS_Dev_Drv_EnableOutEndpoint must be called to allow the Host to write data into the endpoint.

Parameters
baseThe pointer to the USBFS instance.
endpointThe OUT data endpoint number.
bufferThe pointer to the buffer that stores read data.
sizeThe number of bytes to read from the endpoint. This value must be less than or equal to the endpoint maximum packet size.
actSizeThe number of actually read bytes.
contextThe 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.
Returns
The status code of the function execution cy_en_usbfs_dev_drv_status_t.

◆ Cy_USBFS_Dev_Drv_Abort()

cy_en_usbfs_dev_drv_status_t Cy_USBFS_Dev_Drv_Abort ( USBFS_Type *  base,
uint32_t  endpoint,
cy_stc_usbfs_dev_drv_context_t context 
)

Abort operation for data endpoint.

If there is any bus activity after the abort operation requested, the function waits for its completion or a timeout. A timeout is the time to transfer the bulk or an interrupt packet of the maximum playload size. If this bus activity is a transfer to the aborting endpoint, the received data is lost and the endpoint transfer completion callbacks are not invoked. After the function returns a new read or write, the endpoint operation can be submitted.

Parameters
baseThe pointer to the USBFS instance.
endpointThe data endpoint number.
contextThe 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.
Returns
Data endpoint state cy_en_usb_dev_ep_state_t after abort was applied.
Note
  • This abort operation is not supported for the ISOC endpoints because these endpoints do not have a handshake and are always accessible to the USB Host. Therefore, an abort can cause unexpected behavior.
  • The function uses the critical section to protect from the endpoint transfer complete interrupt.

◆ Cy_USBFS_Dev_Drv_GetEndpointAckState()

__STATIC_INLINE bool Cy_USBFS_Dev_Drv_GetEndpointAckState ( USBFS_Type const *  base,
uint32_t  endpoint 
)

Returns whether the transaction completed with ACK for a certain endpoint.

Parameters
baseThe pointer to the USBFS instance.
endpointThe data endpoint number.
Returns
ACK state: true - transaction completed with ACK, false - otherwise.

◆ Cy_USBFS_Dev_Drv_GetEndpointCount()

__STATIC_INLINE uint32_t Cy_USBFS_Dev_Drv_GetEndpointCount ( USBFS_Type const *  base,
uint32_t  endpoint 
)

Returns the number of data bytes in the transaction for a certain endpoint.

Before calling this function, ensure the Host has written data into the endpoint. The returned value is updated after the Host access to the endpoint but remains unchanged after data has been read from the endpoint buffer. A typical use case is to read the number of bytes that the Host wrote into the OUT endpoint.

Parameters
baseThe pointer to the USBFS instance.
endpointThe data endpoint number.
Returns
The number of data bytes in the transaction.

◆ Cy_USBFS_Dev_Drv_StallEndpoint()

cy_en_usbfs_dev_drv_status_t Cy_USBFS_Dev_Drv_StallEndpoint ( USBFS_Type *  base,
uint32_t  endpoint,
cy_stc_usbfs_dev_drv_context_t context 
)

Configures data endpoint to STALL any request intended for it.

Parameters
baseThe pointer to the USBFS instance.
endpointThe data endpoint number.
contextThe 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.
Returns
Status code of the function execution cy_en_usbfs_dev_drv_status_t.

◆ Cy_USBFS_Dev_Drv_UnStallEndpoint()

cy_en_usbfs_dev_drv_status_t Cy_USBFS_Dev_Drv_UnStallEndpoint ( USBFS_Type *  base,
uint32_t  endpoint,
cy_stc_usbfs_dev_drv_context_t context 
)

Release data endpoint STALL condition and clears data toggle bit.

The endpoint is returned to the same state as it was before STALL request.

Parameters
baseThe pointer to the USBFS instance.
endpointThe data endpoint number.
contextThe 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.
Returns
Status code of the function execution cy_en_usbfs_dev_drv_status_t.