Skip to content

Commit de1429b

Browse files
committed
Disable and re-enable USB interrupts while read breakValues from USB CDC
1 parent 2fb8500 commit de1429b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cores/arduino/USB/CDC.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,18 @@ Serial_::operator bool()
298298
}
299299

300300
int32_t Serial_::readBreak() {
301+
// disable the USB interrupt,
302+
// to avoid clearing a breakValue that might occur
303+
// while processing the current break value
304+
NVIC_DisableIRQ((IRQn_Type) USB_IRQn);
305+
301306
int32_t ret = breakValue;
302307

303308
breakValue = -1;
304309

310+
// re-enable the USB interupt
311+
NVIC_EnableIRQ((IRQn_Type) USB_IRQn);
312+
305313
return ret;
306314
}
307315

0 commit comments

Comments
 (0)