usb_hid.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // SPDX-License-Identifier: BSD-3-Clause
  2. // Copyright (c) 2019-2022, Alex Taradov <alex@taradov.com>. All rights reserved.
  3. #ifndef _USB_HID_H_
  4. #define _USB_HID_H_
  5. /*- Includes ----------------------------------------------------------------*/
  6. #include "usb_std.h"
  7. /*- Definitions -------------------------------------------------------------*/
  8. enum
  9. {
  10. USB_HID_DESCRIPTOR = 0x21,
  11. USB_HID_REPORT_DESCRIPTOR = 0x22,
  12. USB_HID_PHYSICAL_DESCRIPTOR = 0x23,
  13. };
  14. enum
  15. {
  16. USB_HID_DEVICE_CLASS = 3, // USB Human Interface Device Class
  17. };
  18. /*- Types -------------------------------------------------------------------*/
  19. typedef struct USB_PACK
  20. {
  21. uint8_t bLength;
  22. uint8_t bDescriptorType;
  23. uint16_t bcdHID;
  24. uint8_t bCountryCode;
  25. uint8_t bNumDescriptors;
  26. uint8_t bDescriptorType1;
  27. uint16_t wDescriptorLength;
  28. } usb_hid_descriptor_t;
  29. /*- Prototypes --------------------------------------------------------------*/
  30. void usb_hid_init(void);
  31. bool usb_hid_handle_request(usb_request_t *request);
  32. void usb_hid_send(uint8_t *data, int size);
  33. void usb_hid_recv(uint8_t *data, int size);
  34. void usb_hid_send_callback(void);
  35. void usb_hid_recv_callback(int size);
  36. #endif // _USB_HID_H_