Skip to content

Commit 2c1462d

Browse files
committed
Disable and re-enable USB interrupts while read breakValues from USB CDC
1 parent 19b8a94 commit 2c1462d

File tree

1 file changed

+8
-0
lines changed
  • hardware/arduino/sam/cores/arduino/USB

1 file changed

+8
-0
lines changed

hardware/arduino/sam/cores/arduino/USB/CDC.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,18 @@ Serial_::operator bool()
309309
}
310310

311311
int32_t Serial_::readBreak() {
312+
// disable the USB OTG interrupt,
313+
// to avoid clearing a breakValue that might occur
314+
// while reading the current break value
315+
NVIC_DisableIRQ((IRQn_Type) ID_UOTGHS);
316+
312317
int32_t ret = breakValue;
313318

314319
breakValue = -1;
315320

321+
// re-eable the USB OTG interupt
322+
NVIC_EnableIRQ((IRQn_Type) ID_UOTGHS);
323+
316324
return ret;
317325
}
318326

0 commit comments

Comments
 (0)