EP0

group group_hal_usb_dev_ep0

APIs relating specifically to management of endpoint zero.

Functions

uint32_t cyhal_usb_dev_ep0_get_max_packet(cyhal_usb_dev_t *obj)

Get wMaxPacketSize of endpoint 0.

The endpoint 0 has dedicated buffer.

Parameters

obj[inout] The USB device object

Returns

The size allocated for endpoint 0

void cyhal_usb_dev_ep0_setup_read_result(cyhal_usb_dev_t *obj, uint8_t *buffer, uint32_t size)

Read the contents of the SETUP packet.

Parameters
  • obj[inout] The USB device object

  • buffer[in] Buffer to fill with data

  • size[in] Size of buffer passed in

void cyhal_usb_dev_ep0_read(cyhal_usb_dev_t *obj, uint8_t *buffer, uint32_t size)

Start receiving a packet of up to wMaxPacketSize on endpoint 0.

Parameters
  • obj[inout] The USB device object

  • buffer[in] Buffer to fill with the data read

  • size[in] Size of buffer

uint32_t cyhal_usb_dev_ep0_read_result(cyhal_usb_dev_t *obj)

Read the contents of a received packet.

Parameters

obj[inout] The USB device object

Returns

Actual number of bytes that was read

uint32_t cyhal_usb_dev_ep0_write(cyhal_usb_dev_t *obj, uint8_t *buffer, uint32_t size)

Write a packet on endpoint 0.

Parameters
  • obj[inout] The USB device object

  • buffer[in] Buffer fill with data to send

  • size[in] Size of data to send

Returns

The number of bytes that were written.

void cyhal_usb_dev_ep0_stall(cyhal_usb_dev_t *obj)

Protocol stall on endpoint 0.

Stall all IN and OUT packets on endpoint 0 until a SETUP packet is received.

note

The stall is cleared automatically when a setup packet is received

Parameters

obj[inout] The USB device object