Service Functions

group group_usb_dev_functions_service

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.

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

Parameters
  • callback: The pointer to a callback function.

  • context: The 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.

__STATIC_INLINE uint32_t Cy_USB_Dev_GetConfiguration (cy_stc_usb_dev_context_t const *context)

Returns USB Device configuration.

Return

Configuration value. The configuration value is 0 until USB Device was not enumerated by the USB Host.

Parameters
  • context: The 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.

__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.

Return

Alternate settings value.

Parameters
  • interface: Interface number.

  • context: The 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.

__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.

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.

Return

True - if configuration has been changed since last call. False - otherwise.

Parameters
  • context: The 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.

__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.

Return

True - if Remote Wakeup was enabled by the USB Host. False - otherwise.

Parameters
  • context: The 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.

__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
  • status: Power status cy_en_usb_dev_power_status_t

  • context: The 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.

__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.

Return

The pointer to the serial number string.

Parameters
  • context: The 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.

__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
  • callback: The pointer to a callback function.

  • context: The 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.

__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.

Return

Returns CY_USB_DEV_SUCCESS (there is input parameters verification).

Parameters
  • transfer: Pointer to structure that holds SETUP packet and information for request processing.

  • ptr: The pointer to the data which will be read by the Host.

  • size: Number of bytes to read.

__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.

Return

Returns CY_USB_DEV_SUCCESS (there is input parameters verification).

Parameters
  • transfer: Pointer to structure that holds SETUP packet and information for request processing.

  • size: Number of bytes which Host is allowed to write.

__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.

Return

Returns CY_USB_DEV_SUCCESS (there is input parameters verification).

Parameters
  • transfer: Pointer to structure that holds SETUP packet and information for request processing.

  • ptr: The pointer to the memory location to copy to.