Functions

group group_usb_dev_hid_functions

Functions

cy_en_usb_dev_status_t Cy_USB_Dev_HID_Init(cy_stc_usb_dev_hid_config_t const *config, cy_stc_usb_dev_hid_context_t *context, cy_stc_usb_dev_context_t *devContext)

Initializes the HID class.

This function must be called to enable USB Device HID functionality.

Return

Status code of the function execution cy_en_usb_dev_status_t.

Parameters
  • config: The pointer to the HID configuration structure cy_stc_usb_dev_hid_config_t.

  • context: The pointer to the context structure cy_stc_usb_dev_hid_context_t allocated by the user. The structure is used during the HID Class operation for internal configuration and data retention. The user must not modify anything in this structure.

  • devContext: The pointer to the USB Device context structure cy_stc_usb_dev_context_t.

cy_en_usb_dev_hid_timer_state_t Cy_USB_Dev_HID_UpdateTimer(uint32_t interface, uint32_t reportId, cy_stc_usb_dev_hid_context_t *context)

Updates the HID Report idle timer and returns the status of the timer.

This function also reloads the timer if it expires.

Return

The state of the HID timer cy_en_usb_dev_hid_timer_state_t

Parameters
  • interface: Contains the interface number that contains the HID descriptor whose HID timer needs to be updated.

  • reportId: Report ID whose HID timer needs to be updated. Pass 0 if report ID is not used.

  • context: The pointer to the context structure cy_stc_usb_dev_hid_context_t allocated by the user. The structure is used during the HID Class operation for internal configuration and data retention. The user must not modify anything in this structure.

__STATIC_INLINE uint32_t Cy_USB_Dev_HID_GetProtocol (uint32_t interface, cy_stc_usb_dev_hid_context_t const *context)

Returns the HID protocol value for a certain interface.

Return

Supported protocol: CY_USB_DEV_HID_PROTOCOL_BOOT or CY_USB_DEV_HID_PROTOCOL_REPORT.

Parameters
  • interface: Interface number.

  • context: The pointer to the context structure cy_stc_usb_dev_hid_context_t allocated by the user. The structure is used during the HID Class operation for internal configuration and data retention. The user must not modify anything in this structure.

__STATIC_INLINE void Cy_USB_Dev_HID_RegisterGetReportCallback (cy_cb_usbfs_dev_hid_get_report_t callback, cy_stc_usb_dev_hid_context_t *context)

Registers a callback function that handles a GET_REPORT request.

The GET_REPORT request is STALLed if the callback function is not registered or returns an error. 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_hid_context_t allocated by the user. The structure is used during the HID Class operation for internal configuration and data retention. The user must not modify anything in this structure.

__STATIC_INLINE void Cy_USB_Dev_HID_RegisterSetReportCallback (cy_cb_usbfs_dev_hid_set_report_t callback, cy_stc_usb_dev_hid_context_t *context)

Registers a callback function that handles SET_REPORT request.

This function is called when data stage of control transfer was completed (USB Device received report data from the USB Host). The SET_REPORT request is STALLed if the callback function is not registered or returns an error. To remove handler, set the handle parameter to NULL and call this function.

Parameters
  • callback: The pointer to a callback function.

  • context: The pointer to the context structure cy_stc_usb_dev_hid_context_t allocated by the user. The structure is used during the HID Class operation for internal configuration and data retention. The user must not modify anything in this structure.

__STATIC_INLINE cy_stc_usb_dev_class_t * Cy_USB_Dev_HID_GetClass (cy_stc_usb_dev_hid_context_t *context)

Returns pointer to the HID class structure.

This function is useful to override class event handlers using Class Support Functions.

Return

The pointer to the HID class structure.

Parameters
  • context: The pointer to the context structure cy_stc_usb_dev_hid_context_t allocated by the user. The structure is used during the HID Class operation for internal configuration and data retention. The user must not modify anything in this structure.