USB device

Header File

Classes

class DeviceDescriptor

Interface to handle device descriptor.

Subclassed by esptinyusb::USBdevice

class esptinyusb::StringDescriptor

USB device strings descriptor.

Public Functions

inline virtual uint8_t getId() final

Get the Id objectGet string descriptor id.

Returns

uint8_t id

inline virtual const char *getDescriptor() final

Get the Descriptor.

Returns

const char* string descriptor value

Header File

Classes

class USBEndpoint

Header File

Classes

class USBInterface

Header File

Enumerations

enum restart_type_t

Values:

enumerator RESTART_NO_PERSIST
enumerator RESTART_PERSIST
enumerator RESTART_BOOTLOADER
enumerator RESTART_BOOTLOADER_DFU
enumerator RESTART_TYPE_MAX

Classes

class esptinyusb::USBdevice : private virtual esptinyusb::DeviceDescriptor

Subclassed by esptinyusb::BaseDevice

Public Functions

virtual uint8_t *getConfigDescriptor() final

Get the Config Descriptor.

Returns

uint8_t*

virtual uint8_t *getDeviceDescriptor() final

Get the Device Descriptor.

Returns

uint8_t*

const uint16_t *getStringDescriptor(uint8_t index, uint16_t langid)

Get the String Descriptor.

Parameters
  • index

  • langid

Returns

const uint16_t*

virtual uint8_t addString(const char *pointer, int8_t id = -1)

Add the string for device descriptor and device class.

Parameters
  • pointer

  • id

Returns

uint8_t

inline virtual void setDescriptor(tusb_desc_device_t &&src)

Set the device descriptor.

Parameters

src

inline virtual void setClass(uint16_t _class, uint16_t subclass, uint16_t protocol) final

Set the USB device descriptor class, subclass and protocol.

Parameters
  • _class

  • subclass

  • protocol

inline virtual void setVidPid(uint16_t vid, uint16_t pid) final

Set the vid and pid.

Parameters
  • vid

  • pid

inline virtual void setVersion(uint16_t device = 0x100, uint16_t usb = 0x200) final

Set the device and usb version in BCD.

Parameters
  • device

  • usb

inline virtual void mfgStringId(uint8_t id) final

Set the manufacturer string id.

Parameters

id

inline virtual void productStringId(uint8_t id) final

Set the product string id.

Parameters

id

inline virtual void serialStringId(uint8_t id) final

Set the serial number string id.

Parameters

id

Public Static Functions

static std::shared_ptr<USBdevice> getInstance()

Get the Instance we want to make USBdevice class a singleton, so all USB class are inheriting from it.

Returns

std::shared_ptr<USBdevice>

class esptinyusb::BaseDevice : public esptinyusb::USBdevice

Base class for all USB class devices, which will inherit from it.

Subclassed by esptinyusb::HIDdevice, esptinyusb::USBWebSerial, esptinyusb::USBcdc, esptinyusb::USBdfu, esptinyusb::USBmsc

Public Functions

virtual bool begin(uint8_t _eps = 1) = 0

begin should add device descriptor and initialize interfaces

Parameters

_eps

Returns

true

Returns

false