Cypress USB Device Middleware Library 2.0
Service Functions

General Description

Functions

__STATIC_INLINE void Cy_USB_Dev_RegisterEventsCallback (cy_cb_usb_dev_events_callback_t callback, cy_stc_usb_dev_context_t *context)
 Registers a callback function to notify number of events: Bus Reset detected, SET_CONFIGURATION request received and SET_INTERFACE request received. More...
 
__STATIC_INLINE uint32_t Cy_USB_Dev_GetConfiguration (cy_stc_usb_dev_context_t const *context)
 Returns USB Device configuration. More...
 
__STATIC_INLINE uint32_t Cy_USB_Dev_GetAlternateSettings (uint32_t interface, cy_stc_usb_dev_context_t const *context)
 Returns alternate setting for a certain interface. More...
 
__STATIC_INLINE bool Cy_USB_Dev_IsConfigurationChanged (cy_stc_usb_dev_context_t *context)
 Returns configuration state that is cleared after read. More...
 
__STATIC_INLINE bool Cy_USB_Dev_IsRemoteWakeupEnabled (cy_stc_usb_dev_context_t const *context)
 Returns Remote Wakeup status. More...
 
__STATIC_INLINE void Cy_USB_Dev_SetPowerStatus (cy_en_usb_dev_power_status_t status, cy_stc_usb_dev_context_t *context)
 Sets Power status to report it when USB Host issues GET_STATUS standard requests. More...
 
__STATIC_INLINE uint8_t * Cy_USB_Dev_GetSerialNumberString (cy_stc_usb_dev_context_t *context)
 Returns pointer to the serial number string generated from silicon ID. More...
 
__STATIC_INLINE void Cy_USB_Dev_RegisterSerialNumStringCallback (cy_fn_usb_dev_sn_string_ptr_t callback, cy_stc_usb_dev_context_t *context)
 Registers a callback function that returns the serial string descriptor when it is requested by the USB Host. More...
 
__STATIC_INLINE cy_en_usb_dev_status_t Cy_USB_Dev_SetupControlRead (cy_stc_usb_dev_control_transfer_t *transfer, uint8_t *ptr, uint32_t size)
 Setup control read (Host reads) transfer. More...
 
__STATIC_INLINE cy_en_usb_dev_status_t Cy_USB_Dev_SetupControlWrite (cy_stc_usb_dev_control_transfer_t *transfer, uint32_t size)
 Setup control write transfer (Host writes) and sets CY_USB_DEV_SUCCESS status. More...
 
__STATIC_INLINE cy_en_usb_dev_status_t Cy_USB_Dev_SetupControlWriteResult (cy_stc_usb_dev_control_transfer_t const *transfer, uint8_t *ptr)
 Copies data received from the Host into the specified memory location. More...
 

Function Documentation

◆ Cy_USB_Dev_RegisterEventsCallback()

__STATIC_INLINE void Cy_USB_Dev_RegisterEventsCallback ( cy_cb_usb_dev_events_callback_t  callback,
cy_stc_usb_dev_context_t context 
)

Registers a callback function to notify number of events: Bus Reset detected, SET_CONFIGURATION request received and SET_INTERFACE request received.

To remove the callback function, pass NULL as the function pointer.

Parameters
callbackThe pointer to a callback function.
contextThe pointer to the context structure cy_stc_usb_dev_context_t allocated by the user. The structure is used during the USB Device operation for internal configuration and data retention. The user must not modify anything in this structure.

◆ Cy_USB_Dev_GetConfiguration()

__STATIC_INLINE uint32_t Cy_USB_Dev_GetConfiguration ( cy_stc_usb_dev_context_t const *  context)

Returns USB Device configuration.

Parameters
contextThe pointer to the context structure cy_stc_usb_dev_context_t allocated by the user. The structure is used during the USB Device operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
Configuration value. The configuration value is 0 until USB Device was not enumerated by the USB Host.

◆ Cy_USB_Dev_GetAlternateSettings()

__STATIC_INLINE uint32_t Cy_USB_Dev_GetAlternateSettings ( uint32_t  interface,
cy_stc_usb_dev_context_t const *  context 
)

Returns alternate setting for a certain interface.

This function is useful to determine which alternate settings are active for a certain interface.

Parameters
interfaceInterface number.
contextThe pointer to the context structure cy_stc_usb_dev_context_t allocated by the user. The structure is used during the USB Device operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
Alternate settings value.

◆ Cy_USB_Dev_IsConfigurationChanged()

__STATIC_INLINE bool Cy_USB_Dev_IsConfigurationChanged ( cy_stc_usb_dev_context_t context)

Returns configuration state that is cleared after read.

This function is useful to determine which configuration or alternate settings of the interface were changed. After configuration state has been changed, Data Transfer Functions functions should be used to start communication with the USB Host.

Parameters
contextThe pointer to the context structure cy_stc_usb_dev_context_t allocated by the user. The structure is used during the USB Device operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
True - if configuration has been changed since last call. False - otherwise.
Note
This function is not interrupt-protected and to prevent a race condition, it should be protected from the USBFS interruption in the place where it is called.

◆ Cy_USB_Dev_IsRemoteWakeupEnabled()

__STATIC_INLINE bool Cy_USB_Dev_IsRemoteWakeupEnabled ( cy_stc_usb_dev_context_t const *  context)

Returns Remote Wakeup status.

This function is useful to determine whether Remote Wakeup was enabled by the USB Host when USB Device supports this option.

Parameters
contextThe pointer to the context structure cy_stc_usb_dev_context_t allocated by the user. The structure is used during the USB Device operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
True - if Remote Wakeup was enabled by the USB Host. False - otherwise.

◆ Cy_USB_Dev_SetPowerStatus()

__STATIC_INLINE void Cy_USB_Dev_SetPowerStatus ( cy_en_usb_dev_power_status_t  status,
cy_stc_usb_dev_context_t context 
)

Sets Power status to report it when USB Host issues GET_STATUS standard requests.

Call this function any time when power source is changed from Self-Powered to Bus-Powered or vice versa.

Parameters
statusPower status cy_en_usb_dev_power_status_t
contextThe pointer to the context structure cy_stc_usb_dev_context_t allocated by the user. The structure is used during the USB Device operation for internal configuration and data retention. The user must not modify anything in this structure.

◆ Cy_USB_Dev_GetSerialNumberString()

__STATIC_INLINE uint8_t * Cy_USB_Dev_GetSerialNumberString ( cy_stc_usb_dev_context_t context)

Returns pointer to the serial number string generated from silicon ID.

The string length is CY_USB_DEV_SN_STRING_LENGTH.

Parameters
contextThe pointer to the context structure cy_stc_usb_dev_context_t allocated by the user. The structure is used during the USB Device operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
The pointer to the serial number string.

◆ Cy_USB_Dev_RegisterSerialNumStringCallback()

__STATIC_INLINE void Cy_USB_Dev_RegisterSerialNumStringCallback ( cy_fn_usb_dev_sn_string_ptr_t  callback,
cy_stc_usb_dev_context_t context 
)

Registers a callback function that returns the serial string descriptor when it is requested by the USB Host.

Parameters
callbackThe pointer to a callback function.
contextThe pointer to the context structure cy_stc_usb_dev_context_t allocated by the user. The structure is used during the USB Device operation for internal configuration and data retention. The user must not modify anything in this structure.

◆ Cy_USB_Dev_SetupControlRead()

__STATIC_INLINE cy_en_usb_dev_status_t Cy_USB_Dev_SetupControlRead ( cy_stc_usb_dev_control_transfer_t transfer,
uint8_t *  ptr,
uint32_t  size 
)

Setup control read (Host reads) transfer.

Parameters
transferPointer to structure that holds SETUP packet and information for request processing.
ptrThe pointer to the data which will be read by the Host.
sizeNumber of bytes to read.
Returns
Returns CY_USB_DEV_SUCCESS (there is input parameters verification).

◆ Cy_USB_Dev_SetupControlWrite()

__STATIC_INLINE cy_en_usb_dev_status_t Cy_USB_Dev_SetupControlWrite ( cy_stc_usb_dev_control_transfer_t transfer,
uint32_t  size 
)

Setup control write transfer (Host writes) and sets CY_USB_DEV_SUCCESS status.

Parameters
transferPointer to structure that holds SETUP packet and information for request processing.
sizeNumber of bytes which Host is allowed to write.
Returns
Returns CY_USB_DEV_SUCCESS (there is input parameters verification).

◆ Cy_USB_Dev_SetupControlWriteResult()

__STATIC_INLINE cy_en_usb_dev_status_t Cy_USB_Dev_SetupControlWriteResult ( cy_stc_usb_dev_control_transfer_t const *  transfer,
uint8_t *  ptr 
)

Copies data received from the Host into the specified memory location.

There must provide enough place to store number of bytes provided in Cy_USB_Dev_SetupControlWrite.

Parameters
transferPointer to structure that holds SETUP packet and information for request processing.
ptrThe pointer to the memory location to copy to.
Returns
Returns CY_USB_DEV_SUCCESS (there is input parameters verification).