Endpoint

group group_hal_usb_dev_endpoint

APIs relating to endpoint management.

Defines

CYHAL_USB_DEV_IS_IN_EP(endpoint)

Returns true if endpoint direction is IN.

CYHAL_USB_DEV_GET_EP_NUM(endpoint)

Returns endpoint number (type uint32_t)

CYHAL_USB_DEV_GET_EP_IDX(endpoint)

Returns endpoint index (type uint32_t)

Enums

enum cyhal_usb_dev_ep_type_t

cyhal_usb_dev_ep_type_t: USB Device Endpoints types.

Values:

enumerator CYHAL_USB_DEV_EP_TYPE_CTRL
enumerator CYHAL_USB_DEV_EP_TYPE_ISO
enumerator CYHAL_USB_DEV_EP_TYPE_BULK
enumerator CYHAL_USB_DEV_EP_TYPE_INT

Functions

cy_rslt_t cyhal_usb_dev_endpoint_add(cyhal_usb_dev_t *obj, bool alloc, bool enable, cyhal_usb_dev_ep_t endpoint, uint32_t max_packet, cyhal_usb_dev_ep_type_t type)

Configure an endpoint.

note

  • This function cannot be used to configure endpoint 0. That must be done with cyhal_usb_dev_ep0_get_max_packet.

  • After endpoint was enabled it must be removed with cyhal_usb_dev_endpoint_remove and then enabled again.

Return

The status of the endpoint add request

Parameters
  • [inout] obj: The USB device object

  • [in] alloc: True to allocates buffer for the endpoint, false to skip allocation

  • [in] enable: True to enable endpoint operation, false to skip enablement

  • [in] endpoint: Endpoint to configure and enable

  • [in] max_packet: The maximum packet size that can be sent or received

  • [in] type: The type of endpoint (does not care when enable parameter is false)

cy_rslt_t cyhal_usb_dev_endpoint_remove(cyhal_usb_dev_t *obj, cyhal_usb_dev_ep_t endpoint)

Disable an endpoint.

Return

The status of the endpoint remove request

Parameters
  • [inout] obj: The USB device object

  • [in] endpoint: Endpoint to disable

cy_rslt_t cyhal_usb_dev_endpoint_stall(cyhal_usb_dev_t *obj, cyhal_usb_dev_ep_t endpoint)

Perform a functional stall on the given endpoint.

Set the HALT feature for this endpoint so that all further communication is aborted.

Return

The status of the endpoint stall request

Parameters
  • [inout] obj: The USB device object

  • [in] endpoint: Endpoint to stall

cy_rslt_t cyhal_usb_dev_endpoint_unstall(cyhal_usb_dev_t *obj, cyhal_usb_dev_ep_t endpoint)

Unstall the endpoint.

Clear the HALT feature on this endpoint so communication can resume.

Return

The status of the endpoint unstall request

Parameters
  • [inout] obj: The USB device object

  • [in] endpoint: Endpoint to stall

bool cyhal_usb_dev_endpoint_is_stalled(cyhal_usb_dev_t *obj, cyhal_usb_dev_ep_t endpoint)

Return the endpoint stall state.

Return

True if endpoint stalled, false otherwise.

Parameters
  • [inout] obj: The USB device object

  • [in] endpoint: Endpoint to check stall state

cy_rslt_t cyhal_usb_dev_endpoint_read(cyhal_usb_dev_t *obj, cyhal_usb_dev_ep_t endpoint, uint8_t *data, uint32_t size)

Start a read on the given endpoint.

Return

The status of start a read operation

Parameters
  • [inout] obj: The USB device object

  • [in] endpoint: Endpoint to start the read on

  • [in] data: Buffer to fill with data

  • [in] size: Size of the read buffer. This must be at least the max packet size for this endpoint.

cy_rslt_t cyhal_usb_dev_endpoint_read_result(cyhal_usb_dev_t *obj, cyhal_usb_dev_ep_t endpoint, uint32_t *act_size)

Finish a read on the given endpoint.

Return

The status of a finish read

Parameters
  • [inout] obj: The USB device object

  • [in] endpoint: Endpoint to check

  • [out] act_size: Actual number of bytes that was read

cy_rslt_t cyhal_usb_dev_endpoint_write(cyhal_usb_dev_t *obj, cyhal_usb_dev_ep_t endpoint, uint8_t const *data, uint32_t size)

Start a write on the given endpoint.

Return

The status of a write request

Parameters
  • [inout] obj: The USB device object

  • [in] endpoint: Endpoint to write to

  • [in] data: Buffer to write

  • [in] size: Size of data to write

cy_rslt_t cyhal_usb_dev_endpoint_abort(cyhal_usb_dev_t *obj, cyhal_usb_dev_ep_t endpoint)

Abort the current transfer if it has not yet been sent.

note

For the ISOC endpoints in pending state this function does not wait for bus activity completion because these endpoints do not have handshake and are always accessible to the Host. Therefore it is safe to call this function for ISOC endpoint when the Host will not access them during abort.

Return

The status of an abort request

Parameters
  • [inout] obj: The USB device object

  • [in] endpoint: Endpoint to abort the transfer on. It is implementation defined if this function has an effect on receive endpoints.

void cyhal_usb_dev_register_endpoint_callback(cyhal_usb_dev_t *obj, cyhal_usb_dev_ep_t endpoint, cyhal_usb_dev_endpoint_callback_t callback)

The USB Device endpoint complete callback handler registration.

Parameters
  • [inout] obj: The USB device object

  • [in] endpoint: Endpoint to registers handler

  • [in] callback: The callback handler which will be invoked when the endpoint comp