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 <rockyowl171@gmail.com>
This commit is contained in:
Ron Smith 2021-08-28 19:46:03 -04:00 committed by Christopher Friedt
commit a0d92453d8

View file

@ -672,6 +672,47 @@ static void uart_sam0_poll_out(const struct device *dev, unsigned char c)
usart->DATA.reg = c; usart->DATA.reg = c;
} }
static int uart_sam0_err_check(const struct device *dev)
{
SercomUsart * const regs = DEV_CFG(dev)->regs;
uint32_t err = 0U;
if (regs->STATUS.reg & SERCOM_USART_STATUS_BUFOVF) {
err |= UART_ERROR_OVERRUN;
}
if (regs->STATUS.reg & SERCOM_USART_STATUS_FERR) {
err |= UART_ERROR_PARITY;
}
if (regs->STATUS.reg & SERCOM_USART_STATUS_PERR) {
err |= UART_ERROR_FRAMING;
}
#if defined(SERCOM_REV500)
if (regs->STATUS.reg & SERCOM_USART_STATUS_ISF) {
err |= UART_BREAK;
}
if (regs->STATUS.reg & SERCOM_USART_STATUS_COLL) {
err |= UART_ERROR_COLLISION;
}
regs->STATUS.reg |= SERCOM_USART_STATUS_BUFOVF
| SERCOM_USART_STATUS_FERR
| SERCOM_USART_STATUS_PERR
| SERCOM_USART_STATUS_COLL
| SERCOM_USART_STATUS_ISF;
#else
regs->STATUS.reg |= SERCOM_USART_STATUS_BUFOVF
| SERCOM_USART_STATUS_FERR
| SERCOM_USART_STATUS_PERR;
#endif
wait_synchronization(regs);
return err;
}
#if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API #if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API
static void uart_sam0_isr(const struct device *dev) static void uart_sam0_isr(const struct device *dev)
@ -836,47 +877,6 @@ static int uart_sam0_irq_update(const struct device *dev)
return 1; return 1;
} }
static int uart_sam0_err_check(const struct device *dev)
{
SercomUsart * const regs = DEV_CFG(dev)->regs;
uint32_t err = 0U;
if (regs->STATUS.reg & SERCOM_USART_STATUS_BUFOVF) {
err |= UART_ERROR_OVERRUN;
}
if (regs->STATUS.reg & SERCOM_USART_STATUS_FERR) {
err |= UART_ERROR_PARITY;
}
if (regs->STATUS.reg & SERCOM_USART_STATUS_PERR) {
err |= UART_ERROR_FRAMING;
}
#if defined(SERCOM_REV500)
if (regs->STATUS.reg & SERCOM_USART_STATUS_ISF) {
err |= UART_BREAK;
}
if (regs->STATUS.reg & SERCOM_USART_STATUS_COLL) {
err |= UART_ERROR_COLLISION;
}
regs->STATUS.reg |= SERCOM_USART_STATUS_BUFOVF
| SERCOM_USART_STATUS_FERR
| SERCOM_USART_STATUS_PERR
| SERCOM_USART_STATUS_COLL
| SERCOM_USART_STATUS_ISF;
#else
regs->STATUS.reg |= SERCOM_USART_STATUS_BUFOVF
| SERCOM_USART_STATUS_FERR
| SERCOM_USART_STATUS_PERR;
#endif
wait_synchronization(regs);
return err;
}
static void uart_sam0_irq_callback_set(const struct device *dev, static void uart_sam0_irq_callback_set(const struct device *dev,
uart_irq_callback_user_data_t cb, uart_irq_callback_user_data_t cb,
void *cb_data) void *cb_data)