Purpose
- String IO procedures
- HW-buffered (FIFO)
Notes
- Kernel is required.
Description
GetString
- The re-designed implementation now uses interrupts to read the received data into the string buffer provided to
GetString
. - Since the RP2040 only provides one interrupt wired to the NVIC for all UART interrupts, there’s one handler for two interrupts:
- as soon as the receive FIFO level has reached its trigger level, its contents are copied to the string buffer;
- if no data is received for a specific amount of clock cycles, the timeout interrupt handling copies the remaining data to the string buffer.
- The interrupt handler disables both interrupts when done.
- The kernel thread initiates the above mechanics, and then awaits the disabling of the interrupts.
- Since we’re using kernel-v1 here, the interrupt handler cannot put the waiting thread directly onto the run-queue.
- The concerns with the former version of the driver regarding FIFO overruns, and the corresponding limitations on the maximum baudrate of the serial line, are not relevant anymore.
FIFO Threshold
Depending on the overall interrupt set-up and configuration of the program, the FIFO threshold that triggers the corresponding interrupt can be chosen differently. Either we opt for more frequent interrupts, but with a shorter run-time using a lower threshold, or less frequent ones with a longer run-time with a higher threshold.
The default is 4/8, ie. 16 FIFO entries. With this configuration, input up to 15 characters, eg. for numbers, is handled exclusively by the timeout interrupt.