12#include <Adafruit_TinyUSB.h>
15#include "../UVCDevice.h"
20inline uint16_t
maxPacketSize() {
return TUD_OPT_HIGH_SPEED ? 512 : 64; }
26 uint16_t bufsize)
override {
27 (void)itfnum_deprecated;
29 if (dev ==
nullptr)
return 0;
31 if (buf ==
nullptr)
return len;
33 TINYUVC_LOGE(
"configuration buffer too small (TINYUVC_CONFIG_BUFFER_SIZE)");
36 const uint8_t itf = TinyUSBDevice.allocInterface(2);
37 const uint8_t ep = TinyUSBDevice.allocEndpoint(TUSB_DIR_IN);
49 if (!TinyUSBDevice.isInitialized()) TinyUSBDevice.begin(0);
52 TinyUSBDevice.setConfigurationBuffer(config,
sizeof(config));
54 itf.setStringDescriptor(dev.
name());
55 if (!TinyUSBDevice.addInterface(itf))
return false;
58 if (TinyUSBDevice.mounted()) {
59 TinyUSBDevice.detach();
61 TinyUSBDevice.attach();
66inline void end(UVCDevice &) {}
72inline uint32_t
millis() { return ::millis(); }
73inline uint32_t
micros() { return ::micros(); }
77 void *p = malloc((size + 3) & ~(
size_t)3);
80inline void freeBuffer(uint8_t *buf) { free(buf); }
#define TINYUVC_CONFIG_BUFFER_SIZE
Definition UVCConfig.h:38
#define TINYUVC_LOGE(...)
Definition UVCLogger.h:75
USB Video Class (UVC 1.1) device - a USB webcam.
Definition UVCDevice.h:95
static UVCDevice *& instance()
The active device.
Definition UVCDevice.h:346
const char * name() const
Definition UVCDevice.h:176
uint16_t descriptorLength() const
Length of the function descriptors.
Definition UVCDevice.h:352
uint16_t buildDescriptor(uint8_t *buf, uint16_t bufLen, uint8_t controlItf, uint8_t endpointIn, uint16_t maxPacketSize, uint8_t stringIndex)
Definition UVCDevice.h:361
TinyUVC: USB Video Class (UVC) device for Arduino and the desktop.