Skip to content

Rx timeout interrupt should be controlled individually #568

Open

Description

@xiongyu0523

I saw this PR 6e6cb52 and some discussion in issue #500.

It is not flexible to have both RX and RX timeout interrupts enabled together. In some cases when UART is used together with DMA, we just want to have the RX timeout (IDLE) to tell CPU that a complete frame is received without triggering a DMA interrupt, and definitely, we do not want each character or FIFO threshold trigger a interrupt

I would suggest using a single function to control each interrupt bit. Even the original one is breaking the single-purpose design principle.

Will be something like, what's your thoughts?

uart_set_tx_irq_enable
uart_set_rx_irq_enable
uart_set_idle_irq_enable
uart_set_error_irq_enable

Activity

  1. changed the title [-]Rx timeout should be controlled individually[/-] [+]Rx timeout interrupt should be controlled individually[/+] on Sep 21, 2021
  2. xiongyu0523 commented on Sep 21, 2021

    @xiongyu0523
    Author
  3. Wren6991 commented on Sep 21, 2021

    @Wren6991
    Contributor

    The RX IRQ function is trying to give a simplified view of RX interrupts, satisfying these rules:

    • When at least one character has been received and not read, there will eventually be an interrupt
    • When all characters have been read, there will be no more interrupts until more are received

    Which can be serviced with simple interrupt handler logic, "when I get an interrupt, read all characters and return". It's not perfect but it hides some of the surprising behaviour details of the PL011, and we could write similar functions for another UART (say, PIO) which satisfy the same conditions above.

    The functions you suggest give better control, but they seem quite specific to the way PL011 interrupts work.

    It is not flexible to have both RX and RX timeout interrupts enabled together. In some cases when UART is used together with DMA, we just want to have the RX timeout (IDLE) to tell CPU that a complete frame is received without triggering a DMA interrupt, and definitely, we do not want each character or FIFO threshold trigger a interrupt

    Sorry, could you give a little more detail here? I'm not sure I fully understand the use case. The DREQ glue does handle SINGLE requests, so there should be no need for the processor to come and tidy up odd bytes from the FIFO when the receiver goes idle.

    Are you saying the DMA is handling all of the data movement, and you want to use the idle IRQ to prompt the processor to scan through the DMA RX buffer at meaningful times?

    At some point, if you are using PL011-specific functionality, you may just want to write your own wrappers

    void pl011_set_idle_irq(uart_hw_t *hw, bool irq) {
        if (irq) {
            hw_set_bits(hw->imsc, UART_UARTIMSC_RTIM_BITS);
        } else {
            hw_clear_bits(hw->imsc, UART_UARTIMSC_RTIM_BITS);
       }
    }
  4. xiongyu0523 commented on Sep 24, 2021

    @xiongyu0523
    Author

    Are you saying the DMA is handling all of the data movement, and you want to use the idle IRQ to prompt the processor to scan through the DMA RX buffer at meaningful times?

    Yes exactly.

    • When I got a DMA interrupt, I know the buffer is full, I readout all data within the data buffer
    • When I get an Idle interrupt, I know the a complete frame is received, I read out the amount of data from the last position of the DMA buffer to the current position.
  5. added this to the none milestone on May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions