Skip to content

Commit d848264

Browse files
committed
User noInterrupts + interrupts to make reading and clearing break value atomic.
Instead of NVIC_DisableIRQ + NVIC_EnableIRQ, as it’s a bit awkward to check if a particular NVIC IRQ is enabled on ARM.
1 parent de1429b commit d848264

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cores/arduino/USB/CDC.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,17 @@ Serial_::operator bool()
298298
}
299299

300300
int32_t Serial_::readBreak() {
301-
// disable the USB interrupt,
301+
// disable interrupts,
302302
// to avoid clearing a breakValue that might occur
303303
// while processing the current break value
304-
NVIC_DisableIRQ((IRQn_Type) USB_IRQn);
304+
noInterrupts();
305305

306306
int32_t ret = breakValue;
307307

308308
breakValue = -1;
309309

310-
// re-enable the USB interupt
311-
NVIC_EnableIRQ((IRQn_Type) USB_IRQn);
310+
// re-enable the interrupts
311+
interrupts();
312312

313313
return ret;
314314
}

0 commit comments

Comments
 (0)