Skip to content

Conversation

nmk456
Copy link

@nmk456 nmk456 commented Jan 27, 2022

The RP2040 has a register to change the UART FIFO level at which an interrupt will be generated, but this is not exposed in the SDK. The only time it is used is within the uart_set_irq_enables function, where it is set to the minimum value. I wrote a function uart_set_irq_fifo_levels to configure it to any of the possible values (1/8, 1/4, 1/2, 3/4, and 7/8 full).

There is a slight inconvenience that uart_set_irq_enables resets them to 1/8, so every time that function is called uart_set_irq_fifo_levels must be called again to set the chosen values. This could potentially be fixed by removing the lines in uart_set_irq_enables that does this, but I didn't want to change the functionality of an existing function to keep backwards compatibility.

I wrote some code to test this function, which can be found here, along with it's output.

@lurch
Copy link
Contributor

lurch commented Jan 27, 2022

I'm not sure if they're relevant to your change here, but see also #548 and #500 and #568

@kilograham kilograham added this to the 1.5.0 milestone Sep 12, 2022
* \param tx_level Transmit interrupt FIFO level select
*/
static inline void uart_set_irq_fifo_levels(uart_inst_t *uart, uart_fifo_level_t rx_level, uart_fifo_level_t tx_level) {
hw_write_masked(&uart_get_hw(uart)->ifls, rx_level << UART_UARTIFLS_RXIFLSEL_LSB, UART_UARTIFLS_RXIFLSEL_BITS);
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like you could do this in one hw_write_masked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants