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.

Return

The size allocated for endpoint 0

Parameters
  • [inout] obj: The USB device object

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
  • [inout] obj: The USB device object

  • [in] buffer: Buffer to fill with data

  • [in] size: 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
  • [inout] obj: The USB device object

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

  • [in] size: Size of buffer

uint32_t cyhal_usb_dev_ep0_read_result(cyhal_usb_dev_t *obj)

Read the contents of a received packet.

Return

Actual number of bytes that was read

Parameters
  • [inout] obj: The USB device object

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

Write a packet on endpoint 0.

Return

The number of bytes that were written.

Parameters
  • [inout] obj: The USB device object

  • [in] buffer: Buffer fill with data to send

  • [in] size: Size of data to send

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
  • [inout] obj: The USB device object