Skip to content

Commit 3ec54b9

Browse files
Support the "SEND_BREAK" CDC command
This is an USB command sent by the computer to a CDC serial port. This command does not do anything but call a weak, empty function, allowing a sketch to override the function and handle it however it wants.
1 parent 0ef4d87 commit 3ec54b9

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

hardware/arduino/avr/cores/arduino/CDC.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ int WEAK CDC_GetInterface(u8* interfaceNum)
6060
return USB_SendControl(TRANSFER_PGM,&_cdcInterface,sizeof(_cdcInterface));
6161
}
6262

63+
void WEAK CDC_SendBreakReceived(uint16_t duration) {}
64+
6365
bool WEAK CDC_Setup(Setup& setup)
6466
{
6567
u8 r = setup.bRequest;
@@ -76,6 +78,10 @@ bool WEAK CDC_Setup(Setup& setup)
7678

7779
if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
7880
{
81+
if (CDC_SEND_BREAK == r)
82+
{
83+
CDC_SendBreakReceived((uint16_t)setup.wValueH << 8 | setup.wValueL);
84+
}
7985
if (CDC_SET_LINE_CODING == r)
8086
{
8187
USB_RecvControl((void*)&_usbLineInfo,7);

hardware/arduino/avr/cores/arduino/USBCore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#define CDC_SET_LINE_CODING 0x20
5656
#define CDC_GET_LINE_CODING 0x21
5757
#define CDC_SET_CONTROL_LINE_STATE 0x22
58+
#define CDC_SEND_BREAK 0x23
5859

5960
#define MSC_RESET 0xFF
6061
#define MSC_GET_MAX_LUN 0xFE

0 commit comments

Comments
 (0)