pof_usb.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include <furi_hal.h>
  3. #include <furi_hal_version.h>
  4. #include <furi_hal_usb.h>
  5. #include <furi_hal_usb_hid.h>
  6. #include "usb.h"
  7. #include "usb_hid.h"
  8. #include "virtual_portal.h"
  9. #define HID_REPORT_TYPE_INPUT 1
  10. #define HID_REPORT_TYPE_OUTPUT 2
  11. #define HID_REPORT_TYPE_FEATURE 3
  12. typedef struct PoFUsb PoFUsb;
  13. PoFUsb* pof_usb_start(VirtualPortal* virtual_portal);
  14. void pof_usb_stop(PoFUsb* pof);
  15. /*descriptor type*/
  16. typedef enum {
  17. PoFDescriptorTypeDevice = 0x01,
  18. PoFDescriptorTypeConfig = 0x02,
  19. PoFDescriptorTypeString = 0x03,
  20. PoFDescriptorTypeInterface = 0x04,
  21. PoFDescriptorTypeEndpoint = 0x05,
  22. } PoFDescriptorType;
  23. /*endpoint direction*/
  24. typedef enum {
  25. PoFEndpointIn = 0x80,
  26. PoFEndpointOut = 0x00,
  27. } PoFEndpointDirection;
  28. /*endpoint type*/
  29. typedef enum {
  30. PoFEndpointTypeCtrl = 0x00,
  31. PoFEndpointTypeIso = 0x01,
  32. PoFEndpointTypeBulk = 0x02,
  33. PoFEndpointTypeIntr = 0x03,
  34. } PoFEndpointType;
  35. /*control request type*/
  36. typedef enum {
  37. PoFControlTypeStandard = (0 << 5),
  38. PoFControlTypeClass = (1 << 5),
  39. PoFControlTypeVendor = (2 << 5),
  40. PoFControlTypeReserved = (3 << 5),
  41. } PoFControlType;
  42. /*control request recipient*/
  43. typedef enum {
  44. PoFControlRecipientDevice = 0,
  45. PoFControlRecipientInterface = 1,
  46. PoFControlRecipientEndpoint = 2,
  47. PoFControlRecipientOther = 3,
  48. } PoFControlRecipient;
  49. /*control request direction*/
  50. typedef enum {
  51. PoFControlOut = 0x00,
  52. PoFControlIn = 0x80,
  53. } PoFControlDirection;
  54. /*endpoint address mask*/
  55. typedef enum {
  56. PoFEndpointAddrMask = 0x0f,
  57. PoFEndpointDirMask = 0x80,
  58. PoFEndpointTransferTypeMask = 0x03,
  59. PoFCtrlDirMask = 0x80,
  60. } PoFEndpointMask;
  61. /* USB control requests */
  62. typedef enum {
  63. PoFControlRequestsOut = (PoFControlTypeVendor | PoFControlRecipientDevice | PoFControlOut),
  64. PoFControlRequestsIn = (PoFControlTypeVendor | PoFControlRecipientDevice | PoFControlIn),
  65. } PoFControlRequests;