Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

follow up to pr #172 #177

Merged
merged 1 commit into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#define USB_PRODUCT "Unknown"
#endif

#ifndef USB_LANGUAGE
#define USB_LANGUAGE 0x0409 // default is English
#endif

#ifndef USB_CONFIG_POWER
#define USB_CONFIG_POWER 100
#endif
Expand Down Expand Up @@ -90,6 +94,7 @@ Adafruit_USBD_Device::Adafruit_USBD_Device(void)
_itf_count = 0;
_epin_count = _epout_count = 1;

_language_id = USB_LANGUAGE;
_manufacturer = USB_MANUFACTURER;
_product = USB_PRODUCT;
}
Expand Down Expand Up @@ -152,12 +157,18 @@ void Adafruit_USBD_Device::setVersion(uint16_t bcd)
_desc_device.bcdUSB = bcd;
}

void Adafruit_USBD_Device::setManufacturer(const char *s)

void Adafruit_USBD_Device::setLanguageDescriptor (uint16_t language_id)
{
_language_id = language_id;
}

void Adafruit_USBD_Device::setManufacturerDescriptor(const char *s)
{
_manufacturer = s;
}

void Adafruit_USBD_Device::setProduct(const char *s)
void Adafruit_USBD_Device::setProductDescriptor(const char *s)
{
_product = s;
}
Expand Down Expand Up @@ -276,17 +287,16 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index)
switch (index)
{
case 0:
// language = English
_desc_str[1] = 0x0409;
_desc_str[1] = USBDevice.getLanguageDescriptor();
chr_count = 1;
break;

case 1:
chr_count = strcpy_uni16(USBDevice.getManufacturer(), _desc_str + 1, 32);
chr_count = strcpy_uni16(USBDevice.getManufacturerDescriptor(), _desc_str + 1, 32);
break;

case 2:
chr_count = strcpy_uni16(USBDevice.getProduct(), _desc_str + 1, 32);
chr_count = strcpy_uni16(USBDevice.getProductDescriptor(), _desc_str + 1, 32);
break;

case 3:
Expand Down
12 changes: 8 additions & 4 deletions cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Adafruit_USBD_Device
uint8_t _epin_count;
uint8_t _epout_count;

uint16_t _language_id;
const char *_manufacturer;
const char *_product;

Expand All @@ -60,10 +61,13 @@ class Adafruit_USBD_Device
void setID(uint16_t vid, uint16_t pid);
void setVersion(uint16_t bcd);

const char *getManufacturer(void) { return _manufacturer; }
void setManufacturer(const char *s);
const char *getProduct(void) { return _product; }
void setProduct(const char *s);
void setLanguageDescriptor(uint16_t language_id);
void setManufacturerDescriptor(const char *s);
void setProductDescriptor(const char *s);

uint16_t getLanguageDescriptor (void) { return _language_id; }
const char *getManufacturerDescriptor (void) { return _manufacturer; }
const char *getProductDescriptor (void) { return _product; }

bool begin(void);

Expand Down