PSoC 6 Hardware Abstraction Layer (HAL)

General Description

Macros

#define CYHAL_USB_DEV_RSLT_ERR   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_USB, 0))
 
#define CYHAL_USB_DEV_RSLT_ERR_BAD_DRV_CFG   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_USB, 1))
 
#define CYHAL_USB_DEV_RSLT_ERR_CLK_CFG   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_USB, 2))
 

Typedefs

typedef void(* cyhal_usb_dev_irq_callback_t) (void)
 
typedef void(* cyhal_usb_dev_event_callback_t) (void)
 
typedef void(* cyhal_usb_dev_sof_callback_t) (uint32_t frame_number)
 

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 }
 

Functions

cy_rslt_t cyhal_usb_dev_init (cyhal_usb_dev_t *obj, cyhal_gpio_t dp, cyhal_gpio_t dm, const cyhal_clock_divider_t *clk)
 
void cyhal_usb_dev_free (cyhal_usb_dev_t *obj)
 
void cyhal_usb_dev_connect (cyhal_usb_dev_t *obj)
 
void cyhal_usb_dev_disconnect (cyhal_usb_dev_t *obj)
 
void cyhal_usb_dev_set_configured (cyhal_usb_dev_t *obj)
 
void cyhal_usb_dev_set_unconfigured (cyhal_usb_dev_t *obj)
 
void cyhal_usb_dev_sof_enable (cyhal_usb_dev_t *obj, bool enable)
 
void cyhal_usb_dev_set_address (cyhal_usb_dev_t *obj, uint8_t address)
 
cy_rslt_t cyhal_usb_dev_register_irq_callback (cyhal_usb_dev_t *obj, cyhal_usb_dev_irq_callback_t callback)
 
void cyhal_usb_dev_irq_enable (cyhal_usb_dev_t *obj, bool enable)
 
void cyhal_usb_dev_process_irq (cyhal_usb_dev_t *obj)
 
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)
 
void cyhal_usb_dev_register_sof_callback (cyhal_usb_dev_t *obj, cyhal_usb_dev_sof_callback_t callback)
 

Macro Definition Documentation

◆ CYHAL_USB_DEV_RSLT_ERR

#define CYHAL_USB_DEV_RSLT_ERR   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_USB, 0))

The usb error

◆ CYHAL_USB_DEV_RSLT_ERR_BAD_DRV_CFG

#define CYHAL_USB_DEV_RSLT_ERR_BAD_DRV_CFG   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_USB, 1))

The driver configuration is not supported by the HAL

◆ CYHAL_USB_DEV_RSLT_ERR_CLK_CFG

#define CYHAL_USB_DEV_RSLT_ERR_CLK_CFG   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_USB, 2))

The configuration of USB clock failed

Typedef Documentation

◆ cyhal_usb_dev_irq_callback_t

typedef void(* cyhal_usb_dev_irq_callback_t) (void)

Callback handler for USB Device interrupt

◆ cyhal_usb_dev_event_callback_t

typedef void(* cyhal_usb_dev_event_callback_t) (void)

Callback handler for the events for USB Device

◆ cyhal_usb_dev_sof_callback_t

typedef void(* cyhal_usb_dev_sof_callback_t) (uint32_t frame_number)

Callback handler for the events for USB Device

Enumeration Type Documentation

◆ cyhal_usb_dev_event_t

Service Callback Events

Enumerator
CYHAL_USB_DEV_EVENT_BUS_RESET 

Callback hooked to bus reset interrupt

CYHAL_USB_DEV_EVENT_EP0_SETUP 

Callback hooked to endpoint 0 SETUP packet interrupt

CYHAL_USB_DEV_EVENT_EP0_IN 

Callback hooked to endpoint 0 IN packet interrupt

CYHAL_USB_DEV_EVENT_EP0_OUT 

Callback hooked to endpoint 0 OUT packet interrupt

Function Documentation

◆ cyhal_usb_dev_init()

cy_rslt_t cyhal_usb_dev_init ( cyhal_usb_dev_t *  obj,
cyhal_gpio_t  dp,
cyhal_gpio_t  dm,
const cyhal_clock_divider_t *  clk 
)

Initialize this USBPhy instance.

Parameters
[in,out]objThe usb device object
[in]dpThe D+ pin to initialize
[in]dmThe D- pin to initialize
[in]clkThe clock to use can be shared, if not provided a new clock will be allocated
Returns
The status of the initialization request

◆ cyhal_usb_dev_free()

void cyhal_usb_dev_free ( cyhal_usb_dev_t *  obj)

Power down this USBPhy instance

Disable interrupts and stop sending events.

Parameters
[in,out]objThe usb device object

◆ cyhal_usb_dev_connect()

void cyhal_usb_dev_connect ( cyhal_usb_dev_t *  obj)

Make the USB phy visible to the USB host

Enable either the D+ or D- pull-up so the host can detect the presence of this device.

Parameters
[in,out]objThe usb device object

◆ cyhal_usb_dev_disconnect()

void cyhal_usb_dev_disconnect ( cyhal_usb_dev_t *  obj)

Detach the USB phy

Disable the D+ and D- pull-up and stop responding to USB traffic.

Parameters
[in,out]objThe usb device object

◆ cyhal_usb_dev_set_configured()

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.

Parameters
[in,out]objThe usb device object

◆ cyhal_usb_dev_set_unconfigured()

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.

Parameters
[in,out]objThe usb device object

◆ cyhal_usb_dev_sof_enable()

void cyhal_usb_dev_sof_enable ( cyhal_usb_dev_t *  obj,
bool  enable 
)

Configure start of frame interrupt enablement.

Parameters
[in,out]objThe usb device object
[in]enableTrue to turn on interrupt and start calling sof callback on every frame, False to turn off interrupt and stop calling sof callback.

◆ cyhal_usb_dev_set_address()

void cyhal_usb_dev_set_address ( cyhal_usb_dev_t *  obj,
uint8_t  address 
)

Set the USBPhy's address

Parameters
[in,out]objThe usb device object
[in]addressThis device's USB address

◆ cyhal_usb_dev_register_irq_callback()

cy_rslt_t cyhal_usb_dev_register_irq_callback ( cyhal_usb_dev_t *  obj,
cyhal_usb_dev_irq_callback_t  callback 
)

The USB Device callback handler registration

Parameters
[in,out]objThe usb device object
[in]callbackThe event handler function which will be invoked when the event fires
Returns
The status of the register_irq_callback request

◆ cyhal_usb_dev_irq_enable()

void cyhal_usb_dev_irq_enable ( cyhal_usb_dev_t *  obj,
bool  enable 
)

Configure USB Device event enablement.

Parameters
[in,out]objThe usb device object
[in]enableTrue to turn on events, False to turn off

◆ cyhal_usb_dev_process_irq()

void cyhal_usb_dev_process_irq ( cyhal_usb_dev_t *  obj)

Default USB Device interrupt handler.

Parameters
[in,out]objThe usb device object

◆ cyhal_usb_dev_register_event_callback()

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.

Parameters
[in,out]objThe usb device object
[in]eventThe event that triggers the callback, see /ref cyhal_usb_dev_event_t
[in]callbackThe callback handler which will be invoked when the interrupt fires

◆ cyhal_usb_dev_register_sof_callback()

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.

Parameters
[in,out]objThe usb device object
[in]callbackThe callback handler which will be invoked when the interrupt fires