Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

UsbRaw.h 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Based on Obdev's AVRUSB code and under the same license.
  3. * Modified by Robin Thoni <robin@rthoni.com>
  4. */
  5. #ifndef __UsbRaw_h__
  6. #define __UsbRaw_h__
  7. #include <avr/pgmspace.h>
  8. #include <avr/interrupt.h>
  9. #include <Arduino.h>
  10. #include "usbdrv.h"
  11. #define CALLBACK_ARGS usbRequest_t* rq, UsbRawDevice* dev, uchar* data, uchar len
  12. #ifndef USB_RAW_DEVICE_BUFFER_SIZE
  13. #define USB_RAW_DEVICE_BUFFER_SIZE 32
  14. #endif
  15. class UsbRawDevice {
  16. public:
  17. UsbRawDevice();
  18. void init();
  19. void poll();
  20. void setData(const uchar* data, uchar len);
  21. void setDataString(const char* data);
  22. void setDataUsbNoMsg();
  23. usbMsgLen_t _usbFunctionSetup(usbRequest_t* rq);
  24. uchar _usbFunctionWrite(uchar *data, uchar len);
  25. void setCallback(void (*callback)(CALLBACK_ARGS));
  26. private:
  27. const uchar* _dataSend;
  28. uchar _dataSendLen;
  29. void (*_callback)(CALLBACK_ARGS);
  30. usbRequest_t _rq;
  31. uchar _dataReceive[USB_RAW_DEVICE_BUFFER_SIZE];
  32. uchar _dataReceivePos;
  33. uchar _dataReceiveLen;
  34. };
  35. extern UsbRawDevice UsbRaw;
  36. #endif // __UsbRaw_h__