Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7c02454

Browse filesBrowse files
committed
added set/get LanguageDescriptor
add Descriptor to setManufacturer/setProduct
1 parent c4f3490 commit 7c02454
Copy full SHA for 7c02454

File tree

2 files changed

+24
-10
lines changed
Filter options

2 files changed

+24
-10
lines changed

‎cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.cpp

Copy file name to clipboardExpand all lines: cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.cpp
+16-6Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#define USB_PRODUCT "Unknown"
3535
#endif
3636

37+
#ifndef USB_LANGUAGE
38+
#define USB_LANGUAGE 0x0409 // default is English
39+
#endif
40+
3741
#ifndef USB_CONFIG_POWER
3842
#define USB_CONFIG_POWER 100
3943
#endif
@@ -90,6 +94,7 @@ Adafruit_USBD_Device::Adafruit_USBD_Device(void)
9094
_itf_count = 0;
9195
_epin_count = _epout_count = 1;
9296

97+
_language_id = USB_LANGUAGE;
9398
_manufacturer = USB_MANUFACTURER;
9499
_product = USB_PRODUCT;
95100
}
@@ -152,12 +157,18 @@ void Adafruit_USBD_Device::setVersion(uint16_t bcd)
152157
_desc_device.bcdUSB = bcd;
153158
}
154159

155-
void Adafruit_USBD_Device::setManufacturer(const char *s)
160+
161+
void Adafruit_USBD_Device::setLanguageDescriptor (uint16_t language_id)
162+
{
163+
_language_id = language_id;
164+
}
165+
166+
void Adafruit_USBD_Device::setManufacturerDescriptor(const char *s)
156167
{
157168
_manufacturer = s;
158169
}
159170

160-
void Adafruit_USBD_Device::setProduct(const char *s)
171+
void Adafruit_USBD_Device::setProductDescriptor(const char *s)
161172
{
162173
_product = s;
163174
}
@@ -276,17 +287,16 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index)
276287
switch (index)
277288
{
278289
case 0:
279-
// language = English
280-
_desc_str[1] = 0x0409;
290+
_desc_str[1] = USBDevice.getLanguageDescriptor();
281291
chr_count = 1;
282292
break;
283293

284294
case 1:
285-
chr_count = strcpy_uni16(USBDevice.getManufacturer(), _desc_str + 1, 32);
295+
chr_count = strcpy_uni16(USBDevice.getManufacturerDescriptor(), _desc_str + 1, 32);
286296
break;
287297

288298
case 2:
289-
chr_count = strcpy_uni16(USBDevice.getProduct(), _desc_str + 1, 32);
299+
chr_count = strcpy_uni16(USBDevice.getProductDescriptor(), _desc_str + 1, 32);
290300
break;
291301

292302
case 3:

‎cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.h

Copy file name to clipboardExpand all lines: cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.h
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class Adafruit_USBD_Device
4848
uint8_t _epin_count;
4949
uint8_t _epout_count;
5050

51+
uint16_t _language_id;
5152
const char *_manufacturer;
5253
const char *_product;
5354

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

63-
const char *getManufacturer(void) { return _manufacturer; }
64-
void setManufacturer(const char *s);
65-
const char *getProduct(void) { return _product; }
66-
void setProduct(const char *s);
64+
void setLanguageDescriptor(uint16_t language_id);
65+
void setManufacturerDescriptor(const char *s);
66+
void setProductDescriptor(const char *s);
67+
68+
uint16_t getLanguageDescriptor (void) { return _language_id; }
69+
const char *getManufacturerDescriptor (void) { return _manufacturer; }
70+
const char *getProductDescriptor (void) { return _product; }
6771

6872
bool begin(void);
6973

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.