File tree 2 files changed +28
-0
lines changed
hardware/arduino/sam/cores/arduino/USB
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ static volatile LineInfo _usbLineInfo = {
55
55
0x00 // lineState
56
56
};
57
57
58
+ static volatile int32_t breakValue = -1 ;
59
+
58
60
_Pragma (" pack(1)" )
59
61
static const CDCDescriptor _cdcInterface =
60
62
{
@@ -144,6 +146,7 @@ bool WEAK CDC_Setup(USBSetup& setup)
144
146
145
147
if (CDC_SEND_BREAK == r)
146
148
{
149
+ breakValue = ((uint16_t )setup.wValueH << 8 ) | setup.wValueL ;
147
150
return true ;
148
151
}
149
152
}
@@ -305,6 +308,14 @@ Serial_::operator bool()
305
308
return result;
306
309
}
307
310
311
+ int32_t Serial_::readBreak () {
312
+ int32_t ret = breakValue;
313
+
314
+ breakValue = -1 ;
315
+
316
+ return ret;
317
+ }
318
+
308
319
unsigned long Serial_::baud () {
309
320
return _usbLineInfo.dwDTERate ;
310
321
}
Original file line number Diff line number Diff line change @@ -63,6 +63,23 @@ class Serial_ : public Stream
63
63
using Print::write; // pull in write(str) from Print
64
64
operator bool ();
65
65
66
+ // This method allows processing "SEND_BREAK" requests sent by
67
+ // the USB host. Those requests indicate that the host wants to
68
+ // send a BREAK signal and are accompanied by a single uint16_t
69
+ // value, specifying the duration of the break. The value 0
70
+ // means to end any current break, while the value 0xffff means
71
+ // to start an indefinite break.
72
+ // readBreak() will return the value of the most recent break
73
+ // request, but will return it at most once, returning -1 when
74
+ // readBreak() is called again (until another break request is
75
+ // received, which is again returned once).
76
+ // This also mean that if two break requests are received
77
+ // without readBreak() being called in between, the value of the
78
+ // first request is lost.
79
+ // Note that the value returned is a long, so it can return
80
+ // 0-0xffff as well as -1.
81
+ int32_t readBreak ();
82
+
66
83
// These return the settings specified by the USB host for the
67
84
// serial port. These aren't really used, but are offered here
68
85
// in case a sketch wants to act on these settings.
You can’t perform that action at this time.
0 commit comments