Skip to content

Commit a0d9245

Browse files
ElectronFluxcfriedt
authored andcommitted
drivers: serial: uart_sam0: move err_check methodout of if guard
Fixes a compile error for the err_check function not being found if if CONFIG_UART_INTERRUPT_DRIVEN is not enabled. Signed-off-by: Ron Smith <[email protected]>
1 parent 4f9ac18 commit a0d9245

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

drivers/serial/uart_sam0.c

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,47 @@ static void uart_sam0_poll_out(const struct device *dev, unsigned char c)
672672
usart->DATA.reg = c;
673673
}
674674

675+
static int uart_sam0_err_check(const struct device *dev)
676+
{
677+
SercomUsart * const regs = DEV_CFG(dev)->regs;
678+
uint32_t err = 0U;
679+
680+
if (regs->STATUS.reg & SERCOM_USART_STATUS_BUFOVF) {
681+
err |= UART_ERROR_OVERRUN;
682+
}
683+
684+
if (regs->STATUS.reg & SERCOM_USART_STATUS_FERR) {
685+
err |= UART_ERROR_PARITY;
686+
}
687+
688+
if (regs->STATUS.reg & SERCOM_USART_STATUS_PERR) {
689+
err |= UART_ERROR_FRAMING;
690+
}
691+
692+
#if defined(SERCOM_REV500)
693+
if (regs->STATUS.reg & SERCOM_USART_STATUS_ISF) {
694+
err |= UART_BREAK;
695+
}
696+
697+
if (regs->STATUS.reg & SERCOM_USART_STATUS_COLL) {
698+
err |= UART_ERROR_COLLISION;
699+
}
700+
701+
regs->STATUS.reg |= SERCOM_USART_STATUS_BUFOVF
702+
| SERCOM_USART_STATUS_FERR
703+
| SERCOM_USART_STATUS_PERR
704+
| SERCOM_USART_STATUS_COLL
705+
| SERCOM_USART_STATUS_ISF;
706+
#else
707+
regs->STATUS.reg |= SERCOM_USART_STATUS_BUFOVF
708+
| SERCOM_USART_STATUS_FERR
709+
| SERCOM_USART_STATUS_PERR;
710+
#endif
711+
712+
wait_synchronization(regs);
713+
return err;
714+
}
715+
675716
#if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API
676717

677718
static void uart_sam0_isr(const struct device *dev)
@@ -836,47 +877,6 @@ static int uart_sam0_irq_update(const struct device *dev)
836877
return 1;
837878
}
838879

839-
static int uart_sam0_err_check(const struct device *dev)
840-
{
841-
SercomUsart * const regs = DEV_CFG(dev)->regs;
842-
uint32_t err = 0U;
843-
844-
if (regs->STATUS.reg & SERCOM_USART_STATUS_BUFOVF) {
845-
err |= UART_ERROR_OVERRUN;
846-
}
847-
848-
if (regs->STATUS.reg & SERCOM_USART_STATUS_FERR) {
849-
err |= UART_ERROR_PARITY;
850-
}
851-
852-
if (regs->STATUS.reg & SERCOM_USART_STATUS_PERR) {
853-
err |= UART_ERROR_FRAMING;
854-
}
855-
856-
#if defined(SERCOM_REV500)
857-
if (regs->STATUS.reg & SERCOM_USART_STATUS_ISF) {
858-
err |= UART_BREAK;
859-
}
860-
861-
if (regs->STATUS.reg & SERCOM_USART_STATUS_COLL) {
862-
err |= UART_ERROR_COLLISION;
863-
}
864-
865-
regs->STATUS.reg |= SERCOM_USART_STATUS_BUFOVF
866-
| SERCOM_USART_STATUS_FERR
867-
| SERCOM_USART_STATUS_PERR
868-
| SERCOM_USART_STATUS_COLL
869-
| SERCOM_USART_STATUS_ISF;
870-
#else
871-
regs->STATUS.reg |= SERCOM_USART_STATUS_BUFOVF
872-
| SERCOM_USART_STATUS_FERR
873-
| SERCOM_USART_STATUS_PERR;
874-
#endif
875-
876-
wait_synchronization(regs);
877-
return err;
878-
}
879-
880880
static void uart_sam0_irq_callback_set(const struct device *dev,
881881
uart_irq_callback_user_data_t cb,
882882
void *cb_data)

0 commit comments

Comments
 (0)