Typedefs | |
typedef uint8_t | cyhal_usb_dev_ep_t |
USB endpoint address (consists from endpoint number and direction) | |
typedef void(* | cyhal_usb_dev_irq_callback_t) (void) |
Callback handler for USB Device interrupt. | |
typedef void(* | cyhal_usb_dev_endpoint_callback_t) (cyhal_usb_dev_ep_t endpoint) |
Callback handler for the transfer completion event for data endpoints (not applicable for endpoint 0) | |
typedef void(* | cyhal_usb_dev_event_callback_t) (void) |
Callback handler for the events for USB Device. | |
typedef void(* | cyhal_usb_dev_sof_callback_t) (uint32_t frame_number) |
Callback handler for the events for USB Device. | |
Enumerations | |
enum | cyhal_usb_dev_event_t { CYHAL_USB_DEV_EVENT_BUS_RESET , CYHAL_USB_DEV_EVENT_EP0_SETUP , CYHAL_USB_DEV_EVENT_EP0_IN , CYHAL_USB_DEV_EVENT_EP0_OUT } |
Service Callback Events. More... | |
Functions | |
cy_rslt_t | cyhal_usb_dev_init (cyhal_usb_dev_t *obj, cyhal_gpio_t dp, cyhal_gpio_t dm, const cyhal_clock_t *clk) |
Initialize the USB instance. More... | |
void | cyhal_usb_dev_free (cyhal_usb_dev_t *obj) |
Power down the USB instance. More... | |
void | cyhal_usb_dev_connect (cyhal_usb_dev_t *obj) |
Make the USB device visible to the USB host. More... | |
void | cyhal_usb_dev_disconnect (cyhal_usb_dev_t *obj) |
Detach the USB device. More... | |
void | cyhal_usb_dev_suspend (cyhal_usb_dev_t *obj) |
Suspend the USB phy. More... | |
void | cyhal_usb_dev_resume (cyhal_usb_dev_t *obj) |
Resume the USB phy from a suspended state. More... | |
void | cyhal_usb_dev_set_configured (cyhal_usb_dev_t *obj) |
Set this device to the configured state. More... | |
void | cyhal_usb_dev_set_unconfigured (cyhal_usb_dev_t *obj) |
Leave the configured state. More... | |
void | cyhal_usb_dev_sof_enable (cyhal_usb_dev_t *obj, bool enable) |
Configure start of frame interrupt enablement. More... | |
void | cyhal_usb_dev_set_address (cyhal_usb_dev_t *obj, uint8_t address) |
Set the USBPhy's address. More... | |
cy_rslt_t | cyhal_usb_dev_register_irq_callback (cyhal_usb_dev_t *obj, cyhal_usb_dev_irq_callback_t callback) |
Register a USB Device callback handler. More... | |
void | cyhal_usb_dev_irq_enable (cyhal_usb_dev_t *obj, bool enable) |
Configure USB Device event enablement. More... | |
void | cyhal_usb_dev_process_irq (cyhal_usb_dev_t *obj) |
Default USB Device interrupt handler. More... | |
void | cyhal_usb_dev_register_event_callback (cyhal_usb_dev_t *obj, cyhal_usb_dev_event_t event, cyhal_usb_dev_event_callback_t callback) |
The USB Device event complete callback handler registration. More... | |
void | cyhal_usb_dev_register_sof_callback (cyhal_usb_dev_t *obj, cyhal_usb_dev_sof_callback_t callback) |
The USB Device start of frame (SOF) complete callback handler registration. More... | |
Service Callback Events.
cy_rslt_t cyhal_usb_dev_init | ( | cyhal_usb_dev_t * | obj, |
cyhal_gpio_t | dp, | ||
cyhal_gpio_t | dm, | ||
const cyhal_clock_t * | clk | ||
) |
Initialize the USB instance.
[out] | obj | Pointer to a USB object. The caller must allocate the memory for this object but the init function will initialize its contents. |
[in] | dp | The D+ pin to initialize |
[in] | dm | The D- pin to initialize |
[in] | clk | The clock to use can be shared, if not provided a new clock will be allocated |
void cyhal_usb_dev_free | ( | cyhal_usb_dev_t * | obj | ) |
Power down the USB instance.
Disable interrupts and stop sending events.
[in,out] | obj | The USB device object |
void cyhal_usb_dev_connect | ( | cyhal_usb_dev_t * | obj | ) |
Make the USB device visible to the USB host.
Enable either the D+ or D- pull-up so the host can detect the presence of this device.
[in,out] | obj | The USB device object |
void cyhal_usb_dev_disconnect | ( | cyhal_usb_dev_t * | obj | ) |
Detach the USB device.
Disable the D+ and D- pull-up and stop responding to USB traffic.
[in,out] | obj | The USB device object |
void cyhal_usb_dev_suspend | ( | cyhal_usb_dev_t * | obj | ) |
Suspend the USB phy.
This allows the device to enter deepsleep. Any data left any USB EP buffers will be lost, when device go into deepsleep. Call cyhal_usb_dev_resume to resume USB from deepsleep.
[in] | obj | The usb device object |
void cyhal_usb_dev_resume | ( | cyhal_usb_dev_t * | obj | ) |
Resume the USB phy from a suspended state.
[in] | obj | The usb device object |
void cyhal_usb_dev_set_configured | ( | cyhal_usb_dev_t * | obj | ) |
Set this device to the configured state.
Enable added endpoints if they are not enabled already.
[in,out] | obj | The USB device object |
void cyhal_usb_dev_set_unconfigured | ( | cyhal_usb_dev_t * | obj | ) |
Leave the configured state.
This is a notification to the USBPhy indicating that the device is leaving the configured state. The USBPhy can disable all endpoints other than endpoint 0.
[in,out] | obj | The USB device object |
void cyhal_usb_dev_sof_enable | ( | cyhal_usb_dev_t * | obj, |
bool | enable | ||
) |
Configure start of frame interrupt enablement.
[in,out] | obj | The USB device object |
[in] | enable | True to turn on interrupt and start calling sof callback on every frame, False to turn off interrupt and stop calling sof callback. |
void cyhal_usb_dev_set_address | ( | cyhal_usb_dev_t * | obj, |
uint8_t | address | ||
) |
Set the USBPhy's address.
[in,out] | obj | The USB device object |
[in] | address | This device's USB address |
cy_rslt_t cyhal_usb_dev_register_irq_callback | ( | cyhal_usb_dev_t * | obj, |
cyhal_usb_dev_irq_callback_t | callback | ||
) |
Register a USB Device callback handler.
This function will be called when the USB interrupt is triggered. This interrupt can be enabled or disabled using cyhal_usb_dev_irq_enable.
[in,out] | obj | The USB device object |
[in] | callback | The event handler function which will be invoked when the event fires |
void cyhal_usb_dev_irq_enable | ( | cyhal_usb_dev_t * | obj, |
bool | enable | ||
) |
Configure USB Device event enablement.
When the interrupt is enabled and triggered, the function specified by cyhal_usb_dev_register_irq_callback will be called.
[in,out] | obj | The usb device object |
[in] | enable | True to turn on events, False to turn off |
void cyhal_usb_dev_process_irq | ( | cyhal_usb_dev_t * | obj | ) |
Default USB Device interrupt handler.
[in,out] | obj | The USB device object |
void cyhal_usb_dev_register_event_callback | ( | cyhal_usb_dev_t * | obj, |
cyhal_usb_dev_event_t | event, | ||
cyhal_usb_dev_event_callback_t | callback | ||
) |
The USB Device event complete callback handler registration.
The events are defined by x type.
[in,out] | obj | The USB device object |
[in] | event | The event that triggers the callback, see cyhal_usb_dev_event_t |
[in] | callback | The callback handler which will be invoked when the interrupt fires |
void cyhal_usb_dev_register_sof_callback | ( | cyhal_usb_dev_t * | obj, |
cyhal_usb_dev_sof_callback_t | callback | ||
) |
The USB Device start of frame (SOF) complete callback handler registration.
[in,out] | obj | The USB device object |
[in] | callback | The callback handler which will be invoked when the interrupt fires |