@@ -58,6 +58,8 @@ static volatile LineInfo _usbLineInfo = {
58
58
0x00 // lineState
59
59
};
60
60
61
+ static volatile int32_t breakValue = -1 ;
62
+
61
63
static CDCDescriptor _cdcInterface = {
62
64
D_IAD (0 , 2 , CDC_COMMUNICATION_INTERFACE_CLASS, CDC_ABSTRACT_CONTROL_MODEL, 0 ),
63
65
@@ -134,6 +136,12 @@ bool CDC_Setup(USBSetup& setup)
134
136
}
135
137
return false ;
136
138
}
139
+
140
+ if (CDC_SEND_BREAK == r)
141
+ {
142
+ breakValue = ((uint16_t )setup.wValueH << 8 ) | setup.wValueL ;
143
+ return false ;
144
+ }
137
145
}
138
146
return false ;
139
147
}
@@ -289,6 +297,50 @@ Serial_::operator bool()
289
297
return result;
290
298
}
291
299
300
+ int32_t Serial_::readBreak () {
301
+ uint8_t enableInterrupts = ((__get_PRIMASK () & 0x1 ) == 0 );
302
+
303
+ // disable interrupts,
304
+ // to avoid clearing a breakValue that might occur
305
+ // while processing the current break value
306
+ __disable_irq ();
307
+
308
+ int32_t ret = breakValue;
309
+
310
+ breakValue = -1 ;
311
+
312
+ if (enableInterrupts) {
313
+ // re-enable the interrupts
314
+ __enable_irq ();
315
+ }
316
+
317
+ return ret;
318
+ }
319
+
320
+ unsigned long Serial_::baud () {
321
+ return _usbLineInfo.dwDTERate ;
322
+ }
323
+
324
+ uint8_t Serial_::stopbits () {
325
+ return _usbLineInfo.bCharFormat ;
326
+ }
327
+
328
+ uint8_t Serial_::paritytype () {
329
+ return _usbLineInfo.bParityType ;
330
+ }
331
+
332
+ uint8_t Serial_::numbits () {
333
+ return _usbLineInfo.bDataBits ;
334
+ }
335
+
336
+ bool Serial_::dtr () {
337
+ return _usbLineInfo.lineState & 0x1 ;
338
+ }
339
+
340
+ bool Serial_::rts () {
341
+ return _usbLineInfo.lineState & 0x2 ;
342
+ }
343
+
292
344
Serial_ SerialUSB (USBDevice);
293
345
294
346
#endif
0 commit comments