Skip to content

Commit 035bfa3

Browse files
AbsoluteCatalystfpistm
authored andcommitted
UART - Remove repetitive NVIC SetPriority calls
Was impossible to change the UART IRQ's priority externally. Now only set once upon initialization.
1 parent 1faf0a0 commit 035bfa3

File tree

1 file changed

+3
-2
lines changed
  • libraries/SrcWrapper/src/stm32

1 file changed

+3
-2
lines changed

libraries/SrcWrapper/src/stm32/uart.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ void uart_init(serial_t *obj, uint32_t baudrate, uint32_t databits, uint32_t par
315315
huart->Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
316316
#endif
317317

318+
/* Set the NVIC priority for future interrupts */
319+
HAL_NVIC_SetPriority(obj->irq, UART_IRQ_PRIO, UART_IRQ_SUBPRIO);
320+
318321
#if defined(LPUART1_BASE)
319322
/*
320323
* Note that LPUART clock source must be in the range
@@ -714,7 +717,6 @@ void uart_attach_rx_callback(serial_t *obj, void (*callback)(serial_t *))
714717
HAL_UART_Receive_IT(uart_handlers[obj->index], &(obj->recv), 1);
715718

716719
/* Enable interrupt */
717-
HAL_NVIC_SetPriority(obj->irq, UART_IRQ_PRIO, UART_IRQ_SUBPRIO);
718720
HAL_NVIC_EnableIRQ(obj->irq);
719721
}
720722

@@ -739,7 +741,6 @@ void uart_attach_tx_callback(serial_t *obj, int (*callback)(serial_t *))
739741
HAL_UART_Transmit_IT(uart_handlers[obj->index], &obj->tx_buff[obj->tx_tail], 1);
740742

741743
/* Enable interrupt */
742-
HAL_NVIC_SetPriority(obj->irq, UART_IRQ_PRIO, UART_IRQ_SUBPRIO);
743744
HAL_NVIC_EnableIRQ(obj->irq);
744745
}
745746

0 commit comments

Comments
 (0)