aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKévin Redon <kredon@sysmocom.de>2018-07-03 16:17:56 +0200
committerKing Kévin <kingkevin@cuvoodoo.info>2018-07-04 17:55:20 +0200
commitfe763b76985f243406db3ac42ece032712c48ae2 (patch)
tree812ab4bda7b8777c50fb9dc8c96ca9db83885c2f
parentc9bd71528979e0e44688761a47ec6ab9ff5c1f46 (diff)
sniffing: decrease USB IRQ prioprity to prevent USART overrun
Handling the USB message queue is done in an ISR and take quite some time. This can cause a USART/SIM sniffing buffer overrun, resulting in data loss. By setting the USB IRQ lower than the USART IRQ, the USB ISR can be interrupted (for short) and no data gets lost. Change-Id: I870a0aa8e251bbb53249c54bfcaa45de5b5a9486
-rw-r--r--firmware/libcommon/source/sniffer.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/firmware/libcommon/source/sniffer.c b/firmware/libcommon/source/sniffer.c
index 1b6d5e7..2a7ae5f 100644
--- a/firmware/libcommon/source/sniffer.c
+++ b/firmware/libcommon/source/sniffer.c
@@ -829,6 +829,10 @@ void Sniffer_init(void)
sniff_usart.base->US_RTOR = 9600-12; /* -12 because the timer starts at the end of the 12 ETU frame */
/* Enable interrupt to indicate when data has been received or timeout occurred */
USART_EnableIt(sniff_usart.base, US_IER_RXRDY | US_IER_TIMEOUT);
+ /* Set USB priority lower than USART to not miss sniffing data (both at 0 per default) */
+ if (NVIC_GetPriority(IRQ_USART_SIM)>=NVIC_GetPriority(UDP_IRQn)) {
+ NVIC_SetPriority(UDP_IRQn, NVIC_GetPriority(IRQ_USART_SIM)+2);
+ }
/* Enable interrupt requests for the USART peripheral */
NVIC_EnableIRQ(IRQ_USART_SIM);