@@ -1209,31 +1209,35 @@ size_t uart_lld_stop_receive(UARTDriver *uartp) {
12091209 * @param[in] uartp pointer to the @p UARTDriver object
12101210 */
12111211void uart_lld_serve_interrupt (UARTDriver * uartp ) {
1212- uint32_t isr ;
1213- USART_TypeDef * u = uartp -> usart ;
1214- uint32_t cr1 = u -> CR1 ;
1215-
1216- /* Reading and clearing status.*/
1217- isr = u -> ISR ;
1218- u -> ICR = isr ;
1219-
1220- if (isr & (USART_ISR_LBDF | USART_ISR_ORE | USART_ISR_NE |
1221- USART_ISR_FE | USART_ISR_PE )) {
1222- _uart_rx_error_isr_code (uartp , translate_errors (isr ));
1223- }
1212+ if (uartp -> config -> irq_cb == NULL ) {
1213+ uint32_t isr ;
1214+ USART_TypeDef * u = uartp -> usart ;
1215+ uint32_t cr1 = u -> CR1 ;
1216+
1217+ /* Reading and clearing status.*/
1218+ isr = u -> ISR ;
1219+ u -> ICR = isr ;
1220+
1221+ if (isr & (USART_ISR_LBDF | USART_ISR_ORE | USART_ISR_NE |
1222+ USART_ISR_FE | USART_ISR_PE )) {
1223+ _uart_rx_error_isr_code (uartp , translate_errors (isr ));
1224+ }
12241225
1225- if ((isr & USART_ISR_TC ) && (cr1 & USART_CR1_TCIE )) {
1226- /* TC interrupt disabled.*/
1227- u -> CR1 = cr1 & ~USART_CR1_TCIE ;
1226+ if ((isr & USART_ISR_TC ) && (cr1 & USART_CR1_TCIE )) {
1227+ /* TC interrupt disabled.*/
1228+ u -> CR1 = cr1 & ~USART_CR1_TCIE ;
12281229
1229- /* End of transmission, a callback is generated.*/
1230- _uart_tx2_isr_code (uartp );
1231- }
1230+ /* End of transmission, a callback is generated.*/
1231+ _uart_tx2_isr_code (uartp );
1232+ }
12321233
1233- /* Timeout interrupt sources are only checked if enabled in CR1.*/
1234- if (((cr1 & USART_CR1_IDLEIE ) && (isr & USART_ISR_IDLE )) ||
1235- ((cr1 & USART_CR1_RTOIE ) && (isr & USART_ISR_RTOF ))) {
1236- _uart_timeout_isr_code (uartp );
1234+ /* Timeout interrupt sources are only checked if enabled in CR1.*/
1235+ if (((cr1 & USART_CR1_IDLEIE ) && (isr & USART_ISR_IDLE )) ||
1236+ ((cr1 & USART_CR1_RTOIE ) && (isr & USART_ISR_RTOF ))) {
1237+ _uart_timeout_isr_code (uartp );
1238+ }
1239+ } else {
1240+ uartp -> config -> irq_cb (uartp );
12371241 }
12381242}
12391243
0 commit comments