Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ArduinoCore-avr
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ArduinoCore-avr
Commits
44dc454b
Unverified
Commit
44dc454b
authored
Oct 01, 2021
by
Martino Facchin
Committed by
GitHub
Oct 01, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #383 from DanielGibson/disable-cdc
Allow disabling CDC with -DCDC_DISABLED
parents
8f8df161
8e823d27
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
1 deletion
+42
-1
cores/arduino/CDC.cpp
cores/arduino/CDC.cpp
+8
-0
cores/arduino/USBCore.cpp
cores/arduino/USBCore.cpp
+17
-1
cores/arduino/USBDesc.h
cores/arduino/USBDesc.h
+17
-0
No files found.
cores/arduino/CDC.cpp
View file @
44dc454b
...
...
@@ -22,6 +22,13 @@
#if defined(USBCON)
#ifndef CDC_ENABLED
#warning "! Disabled serial console via USB (CDC)!"
#warning "! With this change you'll have to use the Arduino's reset button/pin to flash (upload)!"
#else // CDC not disabled
typedef
struct
{
u32
dwDTERate
;
...
...
@@ -299,4 +306,5 @@ int32_t Serial_::readBreak() {
Serial_
Serial
;
#endif
/* if defined(CDC_ENABLED) */
#endif
/* if defined(USBCON) */
cores/arduino/USBCore.cpp
View file @
44dc454b
...
...
@@ -69,8 +69,18 @@ const u8 STRING_MANUFACTURER[] PROGMEM = USB_MANUFACTURER;
#define DEVICE_CLASS 0x02
// DEVICE DESCRIPTOR
#ifdef CDC_ENABLED
const
DeviceDescriptor
USB_DeviceDescriptorIAD
=
D_DEVICE
(
0xEF
,
0x02
,
0x01
,
64
,
USB_VID
,
USB_PID
,
0x100
,
IMANUFACTURER
,
IPRODUCT
,
ISERIAL
,
1
);
#else // CDC_DISABLED
// The default descriptor uses USB class OxEF, subclass 0x02 with protocol 1
// which means "Interface Association Descriptor" - that's needed for the CDC,
// but doesn't make much sense as a default for custom devices when CDC is disabled.
// (0x00 means "Use class information in the Interface Descriptors" which should be generally ok)
const
DeviceDescriptor
USB_DeviceDescriptorIAD
=
D_DEVICE
(
0x00
,
0x00
,
0x00
,
64
,
USB_VID
,
USB_PID
,
0x100
,
IMANUFACTURER
,
IPRODUCT
,
ISERIAL
,
1
);
#endif
//==================================================================
//==================================================================
...
...
@@ -328,10 +338,12 @@ int USB_Send(u8 ep, const void* d, int len)
u8
_initEndpoints
[
USB_ENDPOINTS
]
=
{
0
,
// Control Endpoint
#ifdef CDC_ENABLED
EP_TYPE_INTERRUPT_IN
,
// CDC_ENDPOINT_ACM
EP_TYPE_BULK_OUT
,
// CDC_ENDPOINT_OUT
EP_TYPE_BULK_IN
,
// CDC_ENDPOINT_IN
#endif
// Following endpoints are automatically initialized to 0
};
...
...
@@ -373,10 +385,12 @@ void InitEndpoints()
static
bool
ClassInterfaceRequest
(
USBSetup
&
setup
)
{
#ifdef CDC_ENABLED
u8
i
=
setup
.
wIndex
;
if
(
CDC_ACM_INTERFACE
==
i
)
return
CDC_Setup
(
setup
);
#endif
#ifdef PLUGGABLE_USB_ENABLED
return
PluggableUSB
().
setup
(
setup
);
...
...
@@ -466,7 +480,9 @@ static u8 SendInterfaces()
{
u8
interfaces
=
0
;
#ifdef CDC_ENABLED
CDC_GetInterface
(
&
interfaces
);
#endif
#ifdef PLUGGABLE_USB_ENABLED
PluggableUSB
().
getInterface
(
&
interfaces
);
...
...
cores/arduino/USBDesc.h
View file @
44dc454b
...
...
@@ -26,8 +26,25 @@
#define ISERIAL_MAX_LEN 20
// Uncomment the following line or pass -DCDC_DISABLED to the compiler
// to disable CDC (serial console via USB).
// That's useful if you want to create an USB device (like an USB Boot Keyboard)
// that works even with problematic devices (like KVM switches).
// Keep in mind that with this change you'll have to use the Arduino's
// reset button to be able to flash it.
//#define CDC_DISABLED
#ifndef CDC_DISABLED
#define CDC_ENABLED
#endif
#ifdef CDC_ENABLED
#define CDC_INTERFACE_COUNT 2
#define CDC_ENPOINT_COUNT 3
#else // CDC_DISABLED
#define CDC_INTERFACE_COUNT 0
#define CDC_ENPOINT_COUNT 0
#endif
#define CDC_ACM_INTERFACE 0 // CDC ACM
#define CDC_DATA_INTERFACE 1 // CDC Data
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment