Skip to content

Commit 8c273ea

Browse files
committed
Update Tools->Communications menu to work with PluggabeUSB
1 parent 9118520 commit 8c273ea

File tree

5 files changed

+120
-57
lines changed

5 files changed

+120
-57
lines changed

boards.txt

+68-36
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,31 @@ mattairtech_mt_d21e_bl8k.build.mcu=cortex-m0plus
5353
mattairtech_mt_d21e_bl8k.build.f_cpu=48000000L
5454
mattairtech_mt_d21e_bl8k.build.usb_product="MT-D21E"
5555
mattairtech_mt_d21e_bl8k.build.usb_manufacturer="MattairTech"
56-
mattairtech_mt_d21e_bl8k.build.board=CDC_HID_UART
56+
mattairtech_mt_d21e_bl8k.build.board=CDC_UART
5757
mattairtech_mt_d21e_bl8k.menu.com.cdc_hid_uart=CDC_HID_UART
5858
mattairtech_mt_d21e_bl8k.menu.com.cdc_hid_uart.build.board=CDC_HID_UART
5959
mattairtech_mt_d21e_bl8k.menu.com.cdc_hid_uart.build.pid=0x0856
6060
mattairtech_mt_d21e_bl8k.menu.com.cdc_uart=CDC_UART
6161
mattairtech_mt_d21e_bl8k.menu.com.cdc_uart.build.board=CDC_UART
6262
mattairtech_mt_d21e_bl8k.menu.com.cdc_uart.build.pid=0x0557
63-
mattairtech_mt_d21e_bl8k.menu.com.hid_uart=HID_UART
64-
mattairtech_mt_d21e_bl8k.menu.com.hid_uart.build.board=HID_UART
65-
mattairtech_mt_d21e_bl8k.menu.com.hid_uart.build.pid=0x0856
6663
mattairtech_mt_d21e_bl8k.menu.com.cdc_hid=CDC_HID
6764
mattairtech_mt_d21e_bl8k.menu.com.cdc_hid.build.board=CDC_HID
6865
mattairtech_mt_d21e_bl8k.menu.com.cdc_hid.build.pid=0x0856
6966
mattairtech_mt_d21e_bl8k.menu.com.cdc=CDC_ONLY
7067
mattairtech_mt_d21e_bl8k.menu.com.cdc.build.board=CDC_ONLY
7168
mattairtech_mt_d21e_bl8k.menu.com.cdc.build.pid=0x0557
72-
mattairtech_mt_d21e_bl8k.menu.com.hid=HID_ONLY
73-
mattairtech_mt_d21e_bl8k.menu.com.hid.build.board=HID_ONLY
74-
mattairtech_mt_d21e_bl8k.menu.com.hid.build.pid=0x0856
69+
mattairtech_mt_d21e_bl8k.menu.com.cdc_midi_hid_uart=CDC_MIDI_HID_UART
70+
mattairtech_mt_d21e_bl8k.menu.com.cdc_midi_hid_uart.build.board=CDC_MIDI_HID_UART
71+
mattairtech_mt_d21e_bl8k.menu.com.cdc_midi_hid_uart.build.pid=0x0B34
72+
# mattairtech_mt_d21e_bl8k.menu.com.cdc_msd_hid_uart=CDC_MSD_HID_UART
73+
# mattairtech_mt_d21e_bl8k.menu.com.cdc_msd_hid_uart.build.board=CDC_MSD_HID_UART
74+
# mattairtech_mt_d21e_bl8k.menu.com.cdc_msd_hid_uart.build.pid=0x0B40
75+
# mattairtech_mt_d21e_bl8k.menu.com.cdc_msd_midi_hid_uart=CDC_MSD_MIDI_HID_UART
76+
# mattairtech_mt_d21e_bl8k.menu.com.cdc_msd_midi_hid_uart.build.board=CDC_MSD_MIDI_HID_UART
77+
# mattairtech_mt_d21e_bl8k.menu.com.cdc_msd_midi_hid_uart.build.pid=0x0B41
78+
# mattairtech_mt_d21e_bl8k.menu.com.msd_uart=MSD_UART
79+
# mattairtech_mt_d21e_bl8k.menu.com.msd_uart.build.board=MSD_UART
80+
# mattairtech_mt_d21e_bl8k.menu.com.msd_uart.build.pid=0x0A0C
7581
mattairtech_mt_d21e_bl8k.menu.com.uart=UART_ONLY
7682
mattairtech_mt_d21e_bl8k.menu.com.uart.build.board=UART_ONLY
7783
mattairtech_mt_d21e_bl8k.menu.com.uart.build.pid=0x0856
@@ -115,25 +121,31 @@ mattairtech_mt_d21e_bl8k.menu.cpu.samd21e15a.bootloader.file=zero/samd21e15a_sam
115121
#mattairtech_mt_d21e_bl16k.build.f_cpu=48000000L
116122
#mattairtech_mt_d21e_bl16k.build.usb_product="MT-D21E"
117123
#mattairtech_mt_d21e_bl16k.build.usb_manufacturer="MattairTech"
118-
#mattairtech_mt_d21e_bl16k.build.board=CDC_HID_UART
124+
#mattairtech_mt_d21e_bl16k.build.board=CDC_UART
119125
#mattairtech_mt_d21e_bl16k.menu.com.cdc_hid_uart=CDC_HID_UART
120126
#mattairtech_mt_d21e_bl16k.menu.com.cdc_hid_uart.build.board=CDC_HID_UART
121127
#mattairtech_mt_d21e_bl16k.menu.com.cdc_hid_uart.build.pid=0x0856
122128
#mattairtech_mt_d21e_bl16k.menu.com.cdc_uart=CDC_UART
123129
#mattairtech_mt_d21e_bl16k.menu.com.cdc_uart.build.board=CDC_UART
124130
#mattairtech_mt_d21e_bl16k.menu.com.cdc_uart.build.pid=0x0557
125-
#mattairtech_mt_d21e_bl16k.menu.com.hid_uart=HID_UART
126-
#mattairtech_mt_d21e_bl16k.menu.com.hid_uart.build.board=HID_UART
127-
#mattairtech_mt_d21e_bl16k.menu.com.hid_uart.build.pid=0x0856
128131
#mattairtech_mt_d21e_bl16k.menu.com.cdc_hid=CDC_HID
129132
#mattairtech_mt_d21e_bl16k.menu.com.cdc_hid.build.board=CDC_HID
130133
#mattairtech_mt_d21e_bl16k.menu.com.cdc_hid.build.pid=0x0856
131134
#mattairtech_mt_d21e_bl16k.menu.com.cdc=CDC_ONLY
132135
#mattairtech_mt_d21e_bl16k.menu.com.cdc.build.board=CDC_ONLY
133136
#mattairtech_mt_d21e_bl16k.menu.com.cdc.build.pid=0x0557
134-
#mattairtech_mt_d21e_bl16k.menu.com.hid=HID_ONLY
135-
#mattairtech_mt_d21e_bl16k.menu.com.hid.build.board=HID_ONLY
136-
#mattairtech_mt_d21e_bl16k.menu.com.hid.build.pid=0x0856
137+
#mattairtech_mt_d21e_bl16k.menu.com.cdc_midi_hid_uart=CDC_MIDI_HID_UART
138+
#mattairtech_mt_d21e_bl16k.menu.com.cdc_midi_hid_uart.build.board=CDC_MIDI_HID_UART
139+
#mattairtech_mt_d21e_bl16k.menu.com.cdc_midi_hid_uart.build.pid=0x0B34
140+
# mattairtech_mt_d21e_bl16k.menu.com.cdc_msd_hid_uart=CDC_MSD_HID_UART
141+
# mattairtech_mt_d21e_bl16k.menu.com.cdc_msd_hid_uart.build.board=CDC_MSD_HID_UART
142+
# mattairtech_mt_d21e_bl16k.menu.com.cdc_msd_hid_uart.build.pid=0x0B40
143+
# mattairtech_mt_d21e_bl16k.menu.com.cdc_msd_midi_hid_uart=CDC_MSD_MIDI_HID_UART
144+
# mattairtech_mt_d21e_bl16k.menu.com.cdc_msd_midi_hid_uart.build.board=CDC_MSD_MIDI_HID_UART
145+
# mattairtech_mt_d21e_bl16k.menu.com.cdc_msd_midi_hid_uart.build.pid=0x0B41
146+
# mattairtech_mt_d21e_bl16k.menu.com.msd_uart=MSD_UART
147+
# mattairtech_mt_d21e_bl16k.menu.com.msd_uart.build.board=MSD_UART
148+
# mattairtech_mt_d21e_bl16k.menu.com.msd_uart.build.pid=0x0A0C
137149
#mattairtech_mt_d21e_bl16k.menu.com.uart=UART_ONLY
138150
#mattairtech_mt_d21e_bl16k.menu.com.uart.build.board=UART_ONLY
139151
#mattairtech_mt_d21e_bl16k.menu.com.uart.build.pid=0x0856
@@ -178,25 +190,31 @@ mattairtech_mt_d21e_bl8k.menu.cpu.samd21e15a.bootloader.file=zero/samd21e15a_sam
178190
#mattairtech_mt_d21e_bl0k.build.f_cpu=48000000L
179191
#mattairtech_mt_d21e_bl0k.build.usb_product="MT-D21E"
180192
#mattairtech_mt_d21e_bl0k.build.usb_manufacturer="MattairTech"
181-
#mattairtech_mt_d21e_bl0k.build.board=CDC_HID_UART
193+
#mattairtech_mt_d21e_bl0k.build.board=CDC_UART
182194
#mattairtech_mt_d21e_bl0k.menu.com.cdc_hid_uart=CDC_HID_UART
183195
#mattairtech_mt_d21e_bl0k.menu.com.cdc_hid_uart.build.board=CDC_HID_UART
184196
#mattairtech_mt_d21e_bl0k.menu.com.cdc_hid_uart.build.pid=0x0856
185197
#mattairtech_mt_d21e_bl0k.menu.com.cdc_uart=CDC_UART
186198
#mattairtech_mt_d21e_bl0k.menu.com.cdc_uart.build.board=CDC_UART
187199
#mattairtech_mt_d21e_bl0k.menu.com.cdc_uart.build.pid=0x0557
188-
#mattairtech_mt_d21e_bl0k.menu.com.hid_uart=HID_UART
189-
#mattairtech_mt_d21e_bl0k.menu.com.hid_uart.build.board=HID_UART
190-
#mattairtech_mt_d21e_bl0k.menu.com.hid_uart.build.pid=0x0856
191200
#mattairtech_mt_d21e_bl0k.menu.com.cdc_hid=CDC_HID
192201
#mattairtech_mt_d21e_bl0k.menu.com.cdc_hid.build.board=CDC_HID
193202
#mattairtech_mt_d21e_bl0k.menu.com.cdc_hid.build.pid=0x0856
194203
#mattairtech_mt_d21e_bl0k.menu.com.cdc=CDC_ONLY
195204
#mattairtech_mt_d21e_bl0k.menu.com.cdc.build.board=CDC_ONLY
196205
#mattairtech_mt_d21e_bl0k.menu.com.cdc.build.pid=0x0557
197-
#mattairtech_mt_d21e_bl0k.menu.com.hid=HID_ONLY
198-
#mattairtech_mt_d21e_bl0k.menu.com.hid.build.board=HID_ONLY
199-
#mattairtech_mt_d21e_bl0k.menu.com.hid.build.pid=0x0856
206+
#mattairtech_mt_d21e_bl0k.menu.com.cdc_midi_hid_uart=CDC_MIDI_HID_UART
207+
#mattairtech_mt_d21e_bl0k.menu.com.cdc_midi_hid_uart.build.board=CDC_MIDI_HID_UART
208+
#mattairtech_mt_d21e_bl0k.menu.com.cdc_midi_hid_uart.build.pid=0x0B34
209+
# mattairtech_mt_d21e_bl0k.menu.com.cdc_msd_hid_uart=CDC_MSD_HID_UART
210+
# mattairtech_mt_d21e_bl0k.menu.com.cdc_msd_hid_uart.build.board=CDC_MSD_HID_UART
211+
# mattairtech_mt_d21e_bl0k.menu.com.cdc_msd_hid_uart.build.pid=0x0B40
212+
# mattairtech_mt_d21e_bl0k.menu.com.cdc_msd_midi_hid_uart=CDC_MSD_MIDI_HID_UART
213+
# mattairtech_mt_d21e_bl0k.menu.com.cdc_msd_midi_hid_uart.build.board=CDC_MSD_MIDI_HID_UART
214+
# mattairtech_mt_d21e_bl0k.menu.com.cdc_msd_midi_hid_uart.build.pid=0x0B41
215+
# mattairtech_mt_d21e_bl0k.menu.com.msd_uart=MSD_UART
216+
# mattairtech_mt_d21e_bl0k.menu.com.msd_uart.build.board=MSD_UART
217+
# mattairtech_mt_d21e_bl0k.menu.com.msd_uart.build.pid=0x0A0C
200218
#mattairtech_mt_d21e_bl0k.menu.com.uart=UART_ONLY
201219
#mattairtech_mt_d21e_bl0k.menu.com.uart.build.board=UART_ONLY
202220
#mattairtech_mt_d21e_bl0k.menu.com.uart.build.pid=0x0856
@@ -230,25 +248,31 @@ mattairtech_mt_d11.build.mcu=cortex-m0plus
230248
mattairtech_mt_d11.build.f_cpu=48000000L
231249
mattairtech_mt_d11.build.usb_product="MT-D11"
232250
mattairtech_mt_d11.build.usb_manufacturer="MattairTech"
233-
mattairtech_mt_d11.build.board=CDC_HID_UART
251+
mattairtech_mt_d11.build.board=CDC_UART
234252
mattairtech_mt_d11.menu.com.cdc_hid_uart=CDC_HID_UART
235253
mattairtech_mt_d11.menu.com.cdc_hid_uart.build.board=CDC_HID_UART
236254
mattairtech_mt_d11.menu.com.cdc_hid_uart.build.pid=0x0856
237255
mattairtech_mt_d11.menu.com.cdc_uart=CDC_UART
238256
mattairtech_mt_d11.menu.com.cdc_uart.build.board=CDC_UART
239257
mattairtech_mt_d11.menu.com.cdc_uart.build.pid=0x0557
240-
mattairtech_mt_d11.menu.com.hid_uart=HID_UART
241-
mattairtech_mt_d11.menu.com.hid_uart.build.board=HID_UART
242-
mattairtech_mt_d11.menu.com.hid_uart.build.pid=0x0856
243258
mattairtech_mt_d11.menu.com.cdc_hid=CDC_HID
244259
mattairtech_mt_d11.menu.com.cdc_hid.build.board=CDC_HID
245260
mattairtech_mt_d11.menu.com.cdc_hid.build.pid=0x0856
246261
mattairtech_mt_d11.menu.com.cdc=CDC_ONLY
247262
mattairtech_mt_d11.menu.com.cdc.build.board=CDC_ONLY
248263
mattairtech_mt_d11.menu.com.cdc.build.pid=0x0557
249-
mattairtech_mt_d11.menu.com.hid=HID_ONLY
250-
mattairtech_mt_d11.menu.com.hid.build.board=HID_ONLY
251-
mattairtech_mt_d11.menu.com.hid.build.pid=0x0856
264+
mattairtech_mt_d11.menu.com.cdc_midi_hid_uart=CDC_MIDI_HID_UART
265+
mattairtech_mt_d11.menu.com.cdc_midi_hid_uart.build.board=CDC_MIDI_HID_UART
266+
mattairtech_mt_d11.menu.com.cdc_midi_hid_uart.build.pid=0x0B34
267+
# mattairtech_mt_d11.menu.com.cdc_msd_hid_uart=CDC_MSD_HID_UART
268+
# mattairtech_mt_d11.menu.com.cdc_msd_hid_uart.build.board=CDC_MSD_HID_UART
269+
# mattairtech_mt_d11.menu.com.cdc_msd_hid_uart.build.pid=0x0B40
270+
# mattairtech_mt_d11.menu.com.cdc_msd_midi_hid_uart=CDC_MSD_MIDI_HID_UART
271+
# mattairtech_mt_d11.menu.com.cdc_msd_midi_hid_uart.build.board=CDC_MSD_MIDI_HID_UART
272+
# mattairtech_mt_d11.menu.com.cdc_msd_midi_hid_uart.build.pid=0x0B41
273+
# mattairtech_mt_d11.menu.com.msd_uart=MSD_UART
274+
# mattairtech_mt_d11.menu.com.msd_uart.build.board=MSD_UART
275+
# mattairtech_mt_d11.menu.com.msd_uart.build.pid=0x0A0C
252276
mattairtech_mt_d11.menu.com.uart=UART_ONLY
253277
mattairtech_mt_d11.menu.com.uart.build.board=UART_ONLY
254278
mattairtech_mt_d11.menu.com.uart.build.pid=0x0856
@@ -286,14 +310,18 @@ arduino_zero_native.menu.com.cdc_hid_uart=CDC_HID_UART
286310
arduino_zero_native.menu.com.cdc_hid_uart.build.board=CDC_HID_UART
287311
arduino_zero_native.menu.com.cdc_uart=CDC_UART
288312
arduino_zero_native.menu.com.cdc_uart.build.board=CDC_UART
289-
arduino_zero_native.menu.com.hid_uart=HID_UART
290-
arduino_zero_native.menu.com.hid_uart.build.board=HID_UART
291313
arduino_zero_native.menu.com.cdc_hid=CDC_HID
292314
arduino_zero_native.menu.com.cdc_hid.build.board=CDC_HID
293315
arduino_zero_native.menu.com.cdc=CDC_ONLY
294316
arduino_zero_native.menu.com.cdc.build.board=CDC_ONLY
295-
arduino_zero_native.menu.com.hid=HID_ONLY
296-
arduino_zero_native.menu.com.hid.build.board=HID_ONLY
317+
arduino_zero_native.menu.com.cdc_midi_hid_uart=CDC_MIDI_HID_UART
318+
arduino_zero_native.menu.com.cdc_midi_hid_uart.build.board=CDC_MIDI_HID_UART
319+
# arduino_zero_native.menu.com.cdc_msd_hid_uart=CDC_MSD_HID_UART
320+
# arduino_zero_native.menu.com.cdc_msd_hid_uart.build.board=CDC_MSD_HID_UART
321+
# arduino_zero_native.menu.com.cdc_msd_midi_hid_uart=CDC_MSD_MIDI_HID_UART
322+
# arduino_zero_native.menu.com.cdc_msd_midi_hid_uart.build.board=CDC_MSD_MIDI_HID_UART
323+
# arduino_zero_native.menu.com.msd_uart=MSD_UART
324+
# arduino_zero_native.menu.com.msd_uart.build.board=MSD_UART
297325
arduino_zero_native.menu.com.uart=UART_ONLY
298326
arduino_zero_native.menu.com.uart.build.board=UART_ONLY
299327
arduino_zero_native.menu.com.none=USB_UART_DISABLED
@@ -326,14 +354,18 @@ arduino_zero_native.build.pid=0x804d
326354
#arduino_zero_edbg.menu.com.cdc_hid_uart.build.board=CDC_HID_UART
327355
#arduino_zero_edbg.menu.com.cdc_uart=CDC_UART
328356
#arduino_zero_edbg.menu.com.cdc_uart.build.board=CDC_UART
329-
#arduino_zero_edbg.menu.com.hid_uart=HID_UART
330-
#arduino_zero_edbg.menu.com.hid_uart.build.board=HID_UART
331357
#arduino_zero_edbg.menu.com.cdc_hid=CDC_HID
332358
#arduino_zero_edbg.menu.com.cdc_hid.build.board=CDC_HID
333359
#arduino_zero_edbg.menu.com.cdc=CDC_ONLY
334360
#arduino_zero_edbg.menu.com.cdc.build.board=CDC_ONLY
335-
#arduino_zero_edbg.menu.com.hid=HID_ONLY
336-
#arduino_zero_edbg.menu.com.hid.build.board=HID_ONLY
361+
#arduino_zero_edbg.menu.com.cdc_midi_hid_uart=CDC_MIDI_HID_UART
362+
#arduino_zero_edbg.menu.com.cdc_midi_hid_uart.build.board=CDC_MIDI_HID_UART
363+
# arduino_zero_edbg.menu.com.cdc_msd_hid_uart=CDC_MSD_HID_UART
364+
# arduino_zero_edbg.menu.com.cdc_msd_hid_uart.build.board=CDC_MSD_HID_UART
365+
# arduino_zero_edbg.menu.com.cdc_msd_midi_hid_uart=CDC_MSD_MIDI_HID_UART
366+
# arduino_zero_edbg.menu.com.cdc_msd_midi_hid_uart.build.board=CDC_MSD_MIDI_HID_UART
367+
# arduino_zero_edbg.menu.com.msd_uart=MSD_UART
368+
# arduino_zero_edbg.menu.com.msd_uart.build.board=MSD_UART
337369
#arduino_zero_edbg.menu.com.uart=UART_ONLY
338370
#arduino_zero_edbg.menu.com.uart.build.board=UART_ONLY
339371
#arduino_zero_edbg.menu.com.none=USB_UART_DISABLED

cores/arduino/USB/CDC.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <Arduino.h>
2020
#include <Reset.h> // Needed for auto-reset with 1200bps port touch
21+
#include "USBDesc.h"
2122

2223
#include <stdlib.h>
2324
#include <stdio.h>
@@ -59,7 +60,9 @@ static volatile LineInfo _usbLineInfo = {
5960
};
6061

6162
static CDCDescriptor _cdcInterface = {
63+
#if !defined(CDC_ONLY)
6264
D_IAD(0, 2, CDC_COMMUNICATION_INTERFACE_CLASS, CDC_ABSTRACT_CONTROL_MODEL, 0),
65+
#endif
6366

6467
// CDC communication interface
6568
D_INTERFACE(CDC_ACM_INTERFACE, 1, CDC_COMMUNICATION_INTERFACE_CLASS, CDC_ABSTRACT_CONTROL_MODEL, 0),

cores/arduino/USB/USBCore.cpp

+17-8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "SAMD21_USBDevice.h"
2222
#include "PluggableUSB.h"
23+
#include "USBDesc.h"
2324

2425
#include <stdlib.h>
2526
#include <stdio.h>
@@ -66,8 +67,9 @@ const uint8_t STRING_MANUFACTURER[] = USB_MANUFACTURER;
6667

6768

6869
// DEVICE DESCRIPTOR
69-
const DeviceDescriptor USB_DeviceDescriptorB = D_DEVICE(0xEF, 0x02, 0x01, 64, USB_VID, USB_PID, 0x100, IMANUFACTURER, IPRODUCT, ISERIAL, 1);
7070
const DeviceDescriptor USB_DeviceDescriptor = D_DEVICE(0x00, 0x00, 0x00, 64, USB_VID, USB_PID, 0x100, IMANUFACTURER, IPRODUCT, ISERIAL, 1);
71+
const DeviceDescriptor USB_DeviceDescriptorB = D_DEVICE(0xEF, 0x02, 0x01, 64, USB_VID, USB_PID, 0x100, IMANUFACTURER, IPRODUCT, ISERIAL, 1);
72+
const DeviceDescriptor USB_DeviceDescriptorC = D_DEVICE(0x02, 0x00, 0x00, 64, USB_VID, USB_PID, 0x100, IMANUFACTURER, IPRODUCT, ISERIAL, 1);
7173

7274
//==================================================================
7375

@@ -170,7 +172,7 @@ bool USBDeviceClass::sendDescriptor(USBSetup &setup)
170172
{
171173
uint8_t t = setup.wValueH;
172174
uint8_t desc_length = 0;
173-
bool _cdcComposite;
175+
//bool _cdcComposite;
174176
int ret;
175177
const uint8_t *desc_addr = 0;
176178

@@ -188,10 +190,17 @@ bool USBDeviceClass::sendDescriptor(USBSetup &setup)
188190

189191
if (t == USB_DEVICE_DESCRIPTOR_TYPE)
190192
{
191-
if (setup.wLength == 8)
192-
_cdcComposite = 1;
193-
194-
desc_addr = _cdcComposite ? (const uint8_t*)&USB_DeviceDescriptorB : (const uint8_t*)&USB_DeviceDescriptor;
193+
//if (setup.wLength == 8)
194+
// _cdcComposite = 1;
195+
196+
//desc_addr = _cdcComposite ? (const uint8_t*)&USB_DeviceDescriptorB : (const uint8_t*)&USB_DeviceDescriptor;
197+
#if defined(IAD_PRESENT)
198+
desc_addr = (const uint8_t*)&USB_DeviceDescriptorB;
199+
#elif defined(CDC_ONLY)
200+
desc_addr = (const uint8_t*)&USB_DeviceDescriptorC;
201+
#else
202+
desc_addr = (const uint8_t*)&USB_DeviceDescriptor;
203+
#endif
195204

196205
if (*desc_addr > setup.wLength) {
197206
desc_length = setup.wLength;
@@ -785,11 +794,11 @@ bool USBDeviceClass::handleStandardSetup(USBSetup &setup)
785794
initEndpoints();
786795
_usbConfiguration = setup.wValueL;
787796

788-
#if defined(CDC_ENABLED)
797+
#if defined(CDC_ENABLED)
789798
// Enable interrupt for CDC reception from host (OUT packet)
790799
usbd.epBank1EnableTransferComplete(CDC_ENDPOINT_ACM);
791800
usbd.epBank0EnableTransferComplete(CDC_ENDPOINT_OUT);
792-
#endif
801+
#endif
793802

794803
sendZlp(0);
795804
return true;

cores/arduino/USB/USBDesc.h

+29-13
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,48 @@
1919
#ifndef __USBDESC_H__
2020
#define __USBDESC_H__
2121

22-
// CDC or HID can be enabled together.
22+
#if !defined(ARDUINO_USB_UART_DISABLED) && !defined(ARDUINO_UART_ONLY)
2323
#define PLUGGABLE_USB_ENABLED
24+
#endif
2425

25-
// These are now controlled by the boards.txt menu system
26-
#if defined(ARDUINO_CDC_HID) || defined(ARDUINO_CDC_HID_UART)
27-
#define CDC_ENABLED
28-
#define HID_ENABLED
29-
#elif defined(ARDUINO_CDC_ONLY) || defined(ARDUINO_CDC_UART)
30-
#define CDC_ENABLED
31-
#elif defined(ARDUINO_HID_ONLY) || defined(ARDUINO_HID_UART)
32-
#define HID_ENABLED
33-
#elif defined(ARDUINO_USB_UART_DISABLED) || defined(ARDUINO_UART_ONLY)
34-
// do nothing
26+
// These are controlled by the boards.txt menu system.
27+
// Now that there is Pluggable USB, these will be eliminated
28+
// once an alternate method for USB PID allocation is found.
29+
#if defined(ARDUINO_CDC_ONLY) || defined(ARDUINO_CDC_UART) || defined(ARDUINO_CDC_HID) || defined(ARDUINO_CDC_HID_UART) || defined(ARDUINO_CDC_MIDI_HID_UART) || defined(ARDUINO_CDC_MSD_HID_UART) || defined(ARDUINO_CDC_MSD_MIDI_HID_UART)
30+
#define CDC_ENABLED
31+
#if defined(ARDUINO_CDC_ONLY)
32+
#define CDC_ONLY
3533
#else
36-
#error "USBDesc.h: CDC_ENABLED and HID_ENABLED are now controlled by the boards.txt menu system"
34+
#define IAD_PRESENT
35+
#endif
36+
#endif
37+
38+
#if defined(ARDUINO_HID_ONLY) || defined(ARDUINO_HID_UART) || defined(ARDUINO_CDC_HID) || defined(ARDUINO_CDC_HID_UART) || defined(ARDUINO_CDC_MIDI_HID_UART) || defined(ARDUINO_CDC_MSD_HID_UART) || defined(ARDUINO_CDC_MSD_MIDI_HID_UART)
39+
#define HID_ENABLED
40+
#endif
41+
42+
#if defined(ARDUINO_MIDI_ONLY) || defined(ARDUINO_MIDI_UART) || defined(ARDUINO_CDC_MIDI_HID_UART) || defined(ARDUINO_CDC_MSD_MIDI_HID_UART)
43+
#define MIDI_ENABLED
44+
#define IAD_PRESENT
45+
#endif
46+
47+
#if defined(ARDUINO_MSD_ONLY) || defined(ARDUINO_MSD_UART) || defined(ARDUINO_CDC_MSD_HID_UART) || defined(ARDUINO_CDC_MSD_MIDI_HID_UART)
48+
#define MSD_ENABLED
3749
#endif
3850

51+
3952
#ifdef CDC_ENABLED
4053
#define CDC_INTERFACE_COUNT 2
4154
#define CDC_ENPOINT_COUNT 3
55+
#else
56+
#define CDC_INTERFACE_COUNT 0
57+
#define CDC_ENPOINT_COUNT 0
4258
#endif
4359

4460
// CDC
4561
#define CDC_ACM_INTERFACE 0 // CDC ACM
4662
#define CDC_DATA_INTERFACE 1 // CDC Data
47-
#define CDC_FIRST_ENDPOINT 1
63+
#define CDC_FIRST_ENDPOINT 1
4864
#define CDC_ENDPOINT_ACM 1
4965
#define CDC_ENDPOINT_OUT 2
5066
#define CDC_ENDPOINT_IN 3

libraries/HID/HID.h

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#include <stdint.h>
2323
#include <Arduino.h>
2424
#include "USB/PluggableUSB.h"
25+
#if !defined(HID_ENABLED)
26+
#error Please select an appropriate option that includes HID in the Tools->Communications menu.
27+
#endif
2528

2629
#if defined(USBCON)
2730

0 commit comments

Comments
 (0)