pico-sdk icon indicating copy to clipboard operation
pico-sdk copied to clipboard

Add function to control UART FIFO trigger levels

Open nmk456 opened this issue 3 years ago • 1 comments

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.

nmk456 avatar Jan 27 '22 18:01 nmk456

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

lurch avatar Jan 27 '22 21:01 lurch