drivers: serial: uart_sam0: add uart_irq_tx_complete method for sam0.

sam0 does not currently have a uart_irq_tx_complete method for interrupt
driven mode.
This is especially important since the sam0 platform has seperate
interrupt signals for TX data register empty and TX complete therefore
the TX register being empty does not nessisarily mean the data has been
shifted out.
Drivers should check uart_irq_tx_complete if it needs to guarantee
that the data has been fully transmitted in a hardware agnostic way.

Signed-off-by: Ron Smith <rockyowl171@gmail.com>
This commit is contained in:
Ron Smith 2021-09-03 15:24:16 -04:00 committed by Anas Nashif
parent 5c175cc8e4
commit 847b3205d6

View file

@ -789,14 +789,16 @@ static void uart_sam0_irq_tx_enable(const struct device *dev)
{ {
SercomUsart * const regs = DEV_CFG(dev)->regs; SercomUsart * const regs = DEV_CFG(dev)->regs;
regs->INTENSET.reg = SERCOM_USART_INTENSET_DRE; regs->INTENSET.reg = SERCOM_USART_INTENSET_DRE
| SERCOM_USART_INTENSET_TXC;
} }
static void uart_sam0_irq_tx_disable(const struct device *dev) static void uart_sam0_irq_tx_disable(const struct device *dev)
{ {
SercomUsart * const regs = DEV_CFG(dev)->regs; SercomUsart * const regs = DEV_CFG(dev)->regs;
regs->INTENCLR.reg = SERCOM_USART_INTENCLR_DRE; regs->INTENCLR.reg = SERCOM_USART_INTENCLR_DRE
| SERCOM_USART_INTENCLR_TXC;
} }
static int uart_sam0_irq_tx_ready(const struct device *dev) static int uart_sam0_irq_tx_ready(const struct device *dev)
@ -806,6 +808,13 @@ static int uart_sam0_irq_tx_ready(const struct device *dev)
return (regs->INTFLAG.bit.DRE != 0) && (regs->INTENSET.bit.DRE != 0); return (regs->INTFLAG.bit.DRE != 0) && (regs->INTENSET.bit.DRE != 0);
} }
static int uart_sam0_irq_tx_complete(const struct device *dev)
{
SercomUsart * const regs = DEV_CFG(dev)->regs;
return (regs->INTFLAG.bit.TXC != 0) && (regs->INTENSET.bit.TXC != 0);
}
static void uart_sam0_irq_rx_enable(const struct device *dev) static void uart_sam0_irq_rx_enable(const struct device *dev)
{ {
SercomUsart * const regs = DEV_CFG(dev)->regs; SercomUsart * const regs = DEV_CFG(dev)->regs;
@ -1141,6 +1150,7 @@ static const struct uart_driver_api uart_sam0_driver_api = {
.irq_tx_enable = uart_sam0_irq_tx_enable, .irq_tx_enable = uart_sam0_irq_tx_enable,
.irq_tx_disable = uart_sam0_irq_tx_disable, .irq_tx_disable = uart_sam0_irq_tx_disable,
.irq_tx_ready = uart_sam0_irq_tx_ready, .irq_tx_ready = uart_sam0_irq_tx_ready,
.irq_tx_complete = uart_sam0_irq_tx_complete,
.irq_rx_enable = uart_sam0_irq_rx_enable, .irq_rx_enable = uart_sam0_irq_rx_enable,
.irq_rx_disable = uart_sam0_irq_rx_disable, .irq_rx_disable = uart_sam0_irq_rx_disable,
.irq_rx_ready = uart_sam0_irq_rx_ready, .irq_rx_ready = uart_sam0_irq_rx_ready,