Skip to content
Snippets Groups Projects
Commit 610a937e authored by Sandeep Mistry's avatar Sandeep Mistry Committed by Cristian Maglie
Browse files

Only re-enable IRQ if PRIMASK was 0 before disabling IRQ

parent 261c375c
No related branches found
No related tags found
No related merge requests found
......@@ -166,7 +166,9 @@ void Serial_::accept(void)
uint8_t buffer[CDC_SERIAL_BUFFER_SIZE];
uint32_t len = usb.recv(CDC_ENDPOINT_OUT, &buffer, CDC_SERIAL_BUFFER_SIZE);
noInterrupts();
uint8_t enableInterrupts = ((__get_PRIMASK() & 0x1) == 0);
__disable_irq();
ring_buffer *ringBuffer = &cdc_rx_buffer;
uint32_t i = ringBuffer->head;
......@@ -183,7 +185,9 @@ void Serial_::accept(void)
ringBuffer->full = true;
}
ringBuffer->head = i;
interrupts();
if (enableInterrupts) {
__enable_irq();
}
}
int Serial_::available(void)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment