Skip to content

Port some AVR Serial_ (SerialUSB) API's over #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions cores/arduino/USB/CDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,50 @@ Serial_::operator bool()
return result;
}

int32_t Serial_::readBreak() {
uint8_t enableInterrupts = ((__get_PRIMASK() & 0x1) == 0);

// disable interrupts,
// to avoid clearing a breakValue that might occur
// while processing the current break value
__disable_irq();

int32_t ret = breakValue;

breakValue = -1;

if (enableInterrupts) {
// re-enable the interrupts
__enable_irq();
}

return ret;
}

unsigned long Serial_::baud() {
return _usbLineInfo.dwDTERate;
}

uint8_t Serial_::stopbits() {
return _usbLineInfo.bCharFormat;
}

uint8_t Serial_::paritytype() {
return _usbLineInfo.bParityType;
}

uint8_t Serial_::numbits() {
return _usbLineInfo.bDataBits;
}

bool Serial_::dtr() {
return _usbLineInfo.lineState & 0x1;
}

bool Serial_::rts() {
return _usbLineInfo.lineState & 0x2;
}

Serial_ Serial(USBDevice);

#endif
Expand Down