Skip to content

Commit aebf3cb

Browse files
Port some AVR Serial_ (SerialUSB) API's over (#285)
Co-authored-by: Sandeep Mistry <s.mistry@arduino.cc>
1 parent e16a55b commit aebf3cb

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

cores/arduino/USB/CDC.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,50 @@ Serial_::operator bool()
259259
return result;
260260
}
261261

262+
int32_t Serial_::readBreak() {
263+
uint8_t enableInterrupts = ((__get_PRIMASK() & 0x1) == 0);
264+
265+
// disable interrupts,
266+
// to avoid clearing a breakValue that might occur
267+
// while processing the current break value
268+
__disable_irq();
269+
270+
int32_t ret = breakValue;
271+
272+
breakValue = -1;
273+
274+
if (enableInterrupts) {
275+
// re-enable the interrupts
276+
__enable_irq();
277+
}
278+
279+
return ret;
280+
}
281+
282+
unsigned long Serial_::baud() {
283+
return _usbLineInfo.dwDTERate;
284+
}
285+
286+
uint8_t Serial_::stopbits() {
287+
return _usbLineInfo.bCharFormat;
288+
}
289+
290+
uint8_t Serial_::paritytype() {
291+
return _usbLineInfo.bParityType;
292+
}
293+
294+
uint8_t Serial_::numbits() {
295+
return _usbLineInfo.bDataBits;
296+
}
297+
298+
bool Serial_::dtr() {
299+
return _usbLineInfo.lineState & 0x1;
300+
}
301+
302+
bool Serial_::rts() {
303+
return _usbLineInfo.lineState & 0x2;
304+
}
305+
262306
Serial_ Serial(USBDevice);
263307

264308
#endif

0 commit comments

Comments
 (0)