Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Jan 7, 2021

Use TX FIFO level interrupt if available in hardware. It matches the
Zephyr UART API and avoids "bootstrapping" which is needed when using
the TX edge interrupt ("TI"). TX FIFO has room for up to 32 characters
and will typically reduce the number of interrupts.

The PR also contains a fix for using interrupts with APBUART
implementaitons without FIFO.

Tested with QEMU, TSIM and LEON3 hardware.

tbr-tt added 3 commits January 7, 2021 15:12
This commit aligns the GRLIB APBUART driver with the Zephyr UART API
and fixes an issue where TX interrupt could previously be lost. It
was typically seen during interactive operation in the Zephyr shell.

There is an expectation in the Zephyr UART API that TX ready (i.e. TX
buffer space available) interrupt is a level interrupt, i.e. always
active while there's TX buffer space available. In particular, there's
an expectation that after uart_irq_tx_enable(), the TX interrupt will
immediately fire (assuming free TX buffer space is available).

The APBUART "Transmitter interrupt (CTRL_TI)" does not directly fulfill
this expectation because it is edge triggered and fires when the TX
holding register moves from being non-empty to empty. The solution
is to "bootstrap" interrupt processing by calling user-defined ISR
in irq_tx_enable().

This fix is similar to commit 49bb163 ("drivers: serial:
uart_cmsdk_apb: Fix interrupt-driven operation").

Signed-off-by: Martin Åberg <[email protected]>
Use the UART interrupt support.

Signed-off-by: Martin Åberg <[email protected]>
Use TX FIFO level interrupt if available in hardware. It matches the
Zephyr UART API and avoids "bootstrapping" which is needed when using
the TX edge interrupt ("TI"). TX FIFO has room for up to 32 characters
and will typically reduce the number of interrupts.

Details:
APBUART can be synthesized with or without support for TX/RX FIFO.
Edge interrupts which fire when TX holding register changes and RX data
available are always available, independent of the FIFO configuration.
If FIFO is made available at synthesis time, two additional interrupts
become available: TX FIFO half-empty and RX FIFO half-full. These
are level interrupts.

Signed-off-by: Martin Åberg <[email protected]>
@zephyrbot zephyrbot added the area: UART Universal Asynchronous Receiver-Transmitter label Jan 8, 2021
@zephyrbot zephyrbot requested a review from dcpleung January 8, 2021 14:34
@zephyrbot zephyrbot requested a review from dcpleung January 8, 2021 21:17
@ghost ghost added this to the v2.5.0 milestone Jan 18, 2021
if (DEV_DATA(dev)->usefifo) {
/* Transmitter FIFO full flag is available. */
for (
i = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've increased the line length, so maybe just put this all on one line now.

@nashif nashif merged commit 40ab00a into zephyrproject-rtos:master Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Boards area: UART Universal Asynchronous Receiver-Transmitter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants