Skip to content

Commit 6b7d24e

Browse files
committed
added to sketch iProduct and iManufacturer strings identifying board as either an "Arduino Leonardo" or "Arduino Micro" manufactured by "Arduino LLC"
1 parent 4452de6 commit 6b7d24e

File tree

2 files changed

+24
-46
lines changed

2 files changed

+24
-46
lines changed

hardware/arduino/cores/arduino/USBCore.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
//==================================================================
3535

3636
extern const u16 STRING_LANGUAGE[] PROGMEM;
37-
extern const u16 STRING_SERIAL[] PROGMEM;
37+
extern const u16 STRING_IPRODUCT[] PROGMEM;
38+
extern const u16 STRING_IMANUFACTURER[] PROGMEM;
3839
extern const DeviceDescriptor USB_DeviceDescriptor PROGMEM;
3940
extern const DeviceDescriptor USB_DeviceDescriptorA PROGMEM;
4041

@@ -43,16 +44,18 @@ const u16 STRING_LANGUAGE[2] = {
4344
0x0409 // English
4445
};
4546

46-
#if 0
47-
const u16 STRING_PRODUCT[] = {
48-
(3<<8) | (2+2*10),
49-
PRODUCT_NAME
50-
};
47+
const u16 STRING_IPRODUCT[17] = {
48+
(3<<8) | (2+2*16),
49+
#if USB_PID == USB_PID_LEONARDO
50+
'A','r','d','u','i','n','o',' ','L','e','o','n','a','r','d','o'
51+
#elif USB_PID == USB_PID_MICRO
52+
'A','r','d','u','i','n','o',' ','M','i','c','r','o',' ',' ',' '
5153
#endif
54+
};
5255

53-
const u16 STRING_SERIAL[13] = {
54-
(3<<8) | (2+2*12),
55-
MSC_DISK_SERIAL
56+
const u16 STRING_IMANUFACTURER[12] = {
57+
(3<<8) | (2+2*11),
58+
'A','r','d','u','i','n','o',' ','L','L','C'
5659
};
5760

5861
#ifdef CDC_ENABLED
@@ -63,10 +66,10 @@ const u16 STRING_SERIAL[13] = {
6366

6467
// DEVICE DESCRIPTOR
6568
const DeviceDescriptor USB_DeviceDescriptor =
66-
D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,0,IPRODUCT,ISERIAL,1);
69+
D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
6770

6871
const DeviceDescriptor USB_DeviceDescriptorA =
69-
D_DEVICE(DEVICE_CLASS,0x00,0x00,64,USB_VID,USB_PID,0x100,0,IPRODUCT,ISERIAL,1);
72+
D_DEVICE(DEVICE_CLASS,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
7073

7174
//==================================================================
7275
//==================================================================
@@ -473,8 +476,12 @@ bool SendDescriptor(Setup& setup)
473476
{
474477
if (setup.wValueL == 0)
475478
desc_addr = (const u8*)&STRING_LANGUAGE;
476-
if (setup.wValueL == ISERIAL)
477-
desc_addr = (const u8*)&STRING_SERIAL;
479+
else if (setup.wValueL == IPRODUCT)
480+
desc_addr = (const u8*)&STRING_IPRODUCT;
481+
else if (setup.wValueL == IMANUFACTURER)
482+
desc_addr = (const u8*)&STRING_IMANUFACTURER;
483+
else
484+
return false;
478485
}
479486

480487
if (desc_addr == 0)

hardware/arduino/cores/arduino/USBDesc.h

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#define CDC_ENABLED
2020
#define HID_ENABLED
21-
//#define MSC_ENABLED
2221

2322

2423
#ifdef CDC_ENABLED
@@ -37,14 +36,6 @@
3736
#define HID_ENPOINT_COUNT 0
3837
#endif
3938

40-
#ifdef MSC_ENABLED
41-
#define MSC_INTERFACE_COUNT 1
42-
#define MSC_ENPOINT_COUNT 2
43-
#else
44-
#define MSC_INTERFACE_COUNT 0
45-
#define MSC_ENPOINT_COUNT 0
46-
#endif
47-
4839
#define CDC_ACM_INTERFACE 0 // CDC ACM
4940
#define CDC_DATA_INTERFACE 1 // CDC Data
5041
#define CDC_FIRST_ENDPOINT 1
@@ -56,11 +47,6 @@
5647
#define HID_FIRST_ENDPOINT (CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT)
5748
#define HID_ENDPOINT_INT (HID_FIRST_ENDPOINT)
5849

59-
#define MSC_INTERFACE (HID_INTERFACE + HID_INTERFACE_COUNT) // MSC Interface
60-
#define MSC_FIRST_ENDPOINT (HID_FIRST_ENDPOINT + HID_ENPOINT_COUNT)
61-
#define MSC_ENDPOINT_OUT (MSC_FIRST_ENDPOINT)
62-
#define MSC_ENDPOINT_IN (MSC_FIRST_ENDPOINT+1)
63-
6450
#define INTERFACE_COUNT (MSC_INTERFACE + MSC_INTERFACE_COUNT)
6551

6652
#ifdef CDC_ENABLED
@@ -72,25 +58,10 @@
7258
#define HID_TX HID_ENDPOINT_INT
7359
#endif
7460

75-
#ifdef MSC_ENABLED
76-
#define MSC_RX MSC_ENDPOINT_OUT
77-
#define MSC_TX MSC_ENDPOINT_IN
78-
#endif
79-
80-
81-
#define IMANUFACTURER 0
82-
#define IPRODUCT 0
83-
#define ISERIAL 1 // Only need this for MSC
84-
85-
86-
#define WRITABLE_DIRECTORY // undef saved 56 + 512 RAM
87-
88-
#define FAT_DISK_LABEL 'b','o','o','t','l','o','a','d','e','r',' ' // 11 chars (undef saves 12)
89-
#define FAT_FILE_NAME 'F','I','R','M','W','A','R','E','B','I','N' // 11 chars
90-
#define MSC_DISK_SERIAL '0','0','0','0','0','0','0','0','1','7','0','1' // 12 chars
91-
61+
#define IMANUFACTURER 1
62+
#define IPRODUCT 2
63+
#define USB_PID_LEONARDO 0x0034
64+
#define USB_PID_MICRO 0x0035
9265
#define USB_VID 0x2341 // arduino LLC vid
9366
#define USB_PID ARDUINO_MODEL_USB_PID
94-
#define FAT_OEM_NAME 'l','e','o','n','a','r','d','o' // 8 chars
95-
#define PRODUCT_NAME 'A','r','d','u','i','n','o','l','l','c' // 10
9667

0 commit comments

Comments
 (0)