Skip to content

Commit

Permalink
drop itfnum in signature of Adafruit_USBD_Interface::getInterfaceDesc…
Browse files Browse the repository at this point in the history
…riptor()
  • Loading branch information
hathach committed Jan 30, 2024
1 parent 52fca11 commit 0df71c0
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 30 deletions.
2 changes: 1 addition & 1 deletion examples/Vendor/i2c_tiny_usb_adapter/Adafruit_USBD_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Adafruit_USBD_I2C::Adafruit_USBD_I2C(TwoWire* wire) {
setStringDescriptor("I2C Interface");
}

uint16_t Adafruit_USBD_I2C::getInterfaceDescriptor(uint8_t itfnum_deprecated, uint8_t* buf, uint16_t bufsize) {
uint16_t Adafruit_USBD_I2C::getInterfaceDescriptor(uint8_t* buf, uint16_t bufsize) {
uint8_t itfnum = 0;
uint8_t ep_in = 0;
uint8_t ep_out = 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/Vendor/i2c_tiny_usb_adapter/Adafruit_USBD_I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Adafruit_USBD_I2C : public Adafruit_USBD_Interface {
bool handleControlTransfer(uint8_t rhport, uint8_t stage, tusb_control_request_t const* request);

// from Adafruit_USBD_Interface
virtual uint16_t getInterfaceDescriptor(uint8_t itfnum, uint8_t* buf, uint16_t bufsize);
virtual uint16_t getInterfaceDescriptor(uint8_t* buf, uint16_t bufsize);

private:
TwoWire* _wire;
Expand Down
3 changes: 1 addition & 2 deletions src/arduino/Adafruit_USBD_CDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ Adafruit_USBD_CDC::Adafruit_USBD_CDC(void) { _instance = INVALID_INSTANCE; }

#if CFG_TUD_ENABLED

uint16_t Adafruit_USBD_CDC::getInterfaceDescriptor(uint8_t itfnum_deprecated,
uint8_t *buf,
uint16_t Adafruit_USBD_CDC::getInterfaceDescriptor(uint8_t *buf,
uint16_t bufsize) {
// CDC is mostly always existed for DFU
uint8_t itfnum = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/arduino/Adafruit_USBD_CDC.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ class Adafruit_USBD_CDC : public Stream, public Adafruit_USBD_Interface {
operator bool();

// from Adafruit_USBD_Interface
virtual uint16_t getInterfaceDescriptor(uint8_t itfnum_deprecated,
uint8_t *buf, uint16_t bufsize);
virtual uint16_t getInterfaceDescriptor(uint8_t *buf, uint16_t bufsize);

private:
enum { INVALID_INSTANCE = 0xffu };
Expand Down
4 changes: 2 additions & 2 deletions src/arduino/Adafruit_USBD_Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ void Adafruit_USBD_Device::clearConfiguration(void) {
// - Endpoint number is updated to be unique
bool Adafruit_USBD_Device::addInterface(Adafruit_USBD_Interface &itf) {
uint8_t *desc = _desc_cfg + _desc_cfg_len;
uint16_t const len = itf.getInterfaceDescriptor(
_itf_count, desc, _desc_cfg_maxlen - _desc_cfg_len);
uint16_t const len =
itf.getInterfaceDescriptor(desc, _desc_cfg_maxlen - _desc_cfg_len);

if (!len) {
return false;
Expand Down
5 changes: 2 additions & 3 deletions src/arduino/Adafruit_USBD_Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ class Adafruit_USBD_Interface {

// Get Interface Descriptor
// Fill the descriptor (if buf is not NULL) and return its length
virtual uint16_t getInterfaceDescriptor(uint8_t itfnum, uint8_t *buf,
uint16_t bufsize) = 0;
virtual uint16_t getInterfaceDescriptor(uint8_t *buf, uint16_t bufsize) = 0;
// Get Interface Descriptor Length
uint16_t getInterfaceDescriptorLen() {
return getInterfaceDescriptor(0, NULL, 0);
return getInterfaceDescriptor(NULL, 0);
}

void setStringDescriptor(const char *str);
Expand Down
3 changes: 1 addition & 2 deletions src/arduino/hid/Adafruit_USBD_HID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ uint16_t Adafruit_USBD_HID::makeItfDesc(uint8_t itfnum, uint8_t *buf,
return len;
}

uint16_t Adafruit_USBD_HID::getInterfaceDescriptor(uint8_t itfnum_deprecated,
uint8_t *buf,
uint16_t Adafruit_USBD_HID::getInterfaceDescriptor(uint8_t *buf,
uint16_t bufsize) {
uint8_t itfnum = 0;
uint8_t ep_in = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/arduino/hid/Adafruit_USBD_HID.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ class Adafruit_USBD_HID : public Adafruit_USBD_Interface {
bool mouseButtonRelease(uint8_t report_id);

// from Adafruit_USBD_Interface
virtual uint16_t getInterfaceDescriptor(uint8_t itfnum, uint8_t *buf,
uint16_t bufsize);
virtual uint16_t getInterfaceDescriptor(uint8_t *buf, uint16_t bufsize);

// internal use only
uint16_t makeItfDesc(uint8_t itfnum, uint8_t *buf, uint16_t bufsize,
Expand Down
3 changes: 1 addition & 2 deletions src/arduino/midi/Adafruit_USBD_MIDI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ uint16_t Adafruit_USBD_MIDI::makeItfDesc(uint8_t itfnum, uint8_t *buf,
return desc_len;
}

uint16_t Adafruit_USBD_MIDI::getInterfaceDescriptor(uint8_t itfnum_deprecated,
uint8_t *buf,
uint16_t Adafruit_USBD_MIDI::getInterfaceDescriptor(uint8_t *buf,
uint16_t bufsize) {
uint8_t itfnum = 0;
uint8_t ep_in = 0;
Expand Down
3 changes: 1 addition & 2 deletions src/arduino/midi/Adafruit_USBD_MIDI.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ class Adafruit_USBD_MIDI : public Stream, public Adafruit_USBD_Interface {
bool readPacket(uint8_t packet[4]);

// from Adafruit_USBD_Interface
virtual uint16_t getInterfaceDescriptor(uint8_t itfnum, uint8_t *buf,
uint16_t bufsize);
virtual uint16_t getInterfaceDescriptor(uint8_t *buf, uint16_t bufsize);

// internal use only
uint16_t makeItfDesc(uint8_t itfnum, uint8_t *buf, uint16_t bufsize,
Expand Down
4 changes: 1 addition & 3 deletions src/arduino/msc/Adafruit_USBD_MSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,14 @@ uint16_t Adafruit_USBD_MSC::makeItfDesc(uint8_t itfnum, uint8_t *buf,
return len;
}

uint16_t Adafruit_USBD_MSC::getInterfaceDescriptor(uint8_t itfnum_deprecated,
uint8_t *buf,
uint16_t Adafruit_USBD_MSC::getInterfaceDescriptor(uint8_t *buf,
uint16_t bufsize) {
// null buffer is used to get the length of descriptor only
if (!buf) {
return TUD_MSC_DESC_LEN;
}

uint8_t const itfnum = TinyUSBDevice.allocInterface(1);
;
uint8_t const ep_in = TinyUSBDevice.allocEndpoint(TUSB_DIR_IN);
uint8_t const ep_out = TinyUSBDevice.allocEndpoint(TUSB_DIR_OUT);

Expand Down
3 changes: 1 addition & 2 deletions src/arduino/msc/Adafruit_USBD_MSC.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ class Adafruit_USBD_MSC : public Adafruit_USBD_Interface {
}

// from Adafruit_USBD_Interface
virtual uint16_t getInterfaceDescriptor(uint8_t itfnum, uint8_t *buf,
uint16_t bufsize);
virtual uint16_t getInterfaceDescriptor(uint8_t *buf, uint16_t bufsize);

// internal use only
uint16_t makeItfDesc(uint8_t itfnum, uint8_t *buf, uint16_t bufsize,
Expand Down
3 changes: 1 addition & 2 deletions src/arduino/video/Adafruit_USBD_Video.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class Adafruit_USBD_Video : public Adafruit_USBD_Interface {
// bool isStreaming(uint8_t stream_idx);

// from Adafruit_USBD_Interface
virtual uint16_t getInterfaceDescriptor(uint8_t itfnum, uint8_t *buf,
uint16_t bufsize);
virtual uint16_t getInterfaceDescriptor(uint8_t *buf, uint16_t bufsize);

private:
uint8_t const *_desc_itf;
Expand Down
3 changes: 1 addition & 2 deletions src/arduino/webusb/Adafruit_USBD_WebUSB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ uint16_t Adafruit_USBD_WebUSB::makeItfDesc(uint8_t itfnum, uint8_t *buf,
return len;
}

uint16_t Adafruit_USBD_WebUSB::getInterfaceDescriptor(uint8_t itfnum_deprecated,
uint8_t *buf,
uint16_t Adafruit_USBD_WebUSB::getInterfaceDescriptor(uint8_t *buf,
uint16_t bufsize) {
if (!buf) {
return TUD_VENDOR_DESC_LEN;
Expand Down
3 changes: 1 addition & 2 deletions src/arduino/webusb/Adafruit_USBD_WebUSB.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ class Adafruit_USBD_WebUSB : public Stream, public Adafruit_USBD_Interface {
operator bool();

// from Adafruit_USBD_Interface
virtual uint16_t getInterfaceDescriptor(uint8_t itfnum, uint8_t *buf,
uint16_t bufsize);
virtual uint16_t getInterfaceDescriptor(uint8_t *buf, uint16_t bufsize);

// internal use only
uint16_t makeItfDesc(uint8_t itfnum, uint8_t *buf, uint16_t bufsize,
Expand Down

0 comments on commit 0df71c0

Please sign in to comment.