USBIO.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * TI Voxel Lib component.
  3. *
  4. * Copyright (c) 2014 Texas Instruments Inc.
  5. */
  6. #ifndef VOXEL_USBIO_H
  7. #define VOXEL_USBIO_H
  8. #include "Device.h"
  9. #include "USBSystem.h"
  10. #include "Logger.h"
  11. namespace Voxel
  12. {
  13. class VOXEL_EXPORT USBIO
  14. {
  15. protected:
  16. class USBIOPrivate;
  17. Ptr<USBIOPrivate> _usbIOPrivate;
  18. public:
  19. USBIO(DevicePtr device);
  20. enum Direction
  21. {
  22. TO_DEVICE = 0,
  23. FROM_DEVICE = 1
  24. };
  25. enum RequestType
  26. {
  27. REQUEST_STANDARD = 0,
  28. REQUEST_CLASS = 1,
  29. REQUEST_VENDOR = 2,
  30. REQUEST_RESERVED = 3,
  31. };
  32. enum RecipientType
  33. {
  34. RECIPIENT_DEVICE = 0x00,
  35. RECIPIENT_INTERFACE = 0x01,
  36. RECIPIENT_ENDPOINT = 0x02,
  37. RECIPIENT_OTHER = 0x03,
  38. };
  39. bool controlTransfer(Direction direction, RequestType requestType, RecipientType recipientType, uint8_t request, uint16_t value, uint16_t index,
  40. uint8_t *data, uint16_t &length, bool needFullLength = true, long timeout = 1000);
  41. bool bulkTransfer(uint8_t endpoint, uint8_t *data, long toTransferLength, long &transferredLength, long timeout = 1000);
  42. bool resetBulkEndPoint(uint8_t endpoint);
  43. USBSystem &getUSBSystem();
  44. bool isInitialized();
  45. virtual ~USBIO() {}
  46. };
  47. typedef Ptr<USBIO> USBIOPtr;
  48. }
  49. #endif