Skip to content

Commit 72ea3cf

Browse files
committed
Use __get_PRIMASK to determine is interrupts should be enabled in Serial_::readBreak
1 parent d848264 commit 72ea3cf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cores/arduino/USB/CDC.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ Serial_::operator bool()
298298
}
299299

300300
int32_t Serial_::readBreak() {
301+
uint8_t enableInterrupts = (__get_PRIMASK() == 0);
302+
301303
// disable interrupts,
302304
// to avoid clearing a breakValue that might occur
303305
// while processing the current break value
@@ -307,8 +309,10 @@ int32_t Serial_::readBreak() {
307309

308310
breakValue = -1;
309311

310-
// re-enable the interrupts
311-
interrupts();
312+
if (enableInterrupts) {
313+
// re-enable the interrupts
314+
interrupts();
315+
}
312316

313317
return ret;
314318
}

0 commit comments

Comments
 (0)