stm32: Implement Asynchronous UART TX
I am attempting to write large blocks (eg: 2048 bytes) of data to the UART at low baudrates whilst attempting to execute other code. I've discovered that the UART TX is actually blocking until the write is completed. This is a bit of a pain...
This issue is for creating an asynchronous write option for UART. Related to #1533
Probably either interrupt or DMA driven. Should ideally behave like the UART RX does, with a definable buffer in python code, or block as it currently does.
Reading related issues it seems like #1422 has had some success using DMA. Personally, I don't require the callback as I'm not streaming from a file, just an existing bytearray in memory.
I haven't had a chance to read the huge threads on some of the issues I've found so I'm not 100% up to date yet...
In the machine library and/or the pyb library, add a non-blocking UART transmit polling function
Description
STM32 UART.c inlines (via UART.h) the testing of the UART tx available bit and does not make the result publically available. This by definition eliminates the simplest way to implement cooperative multitasking, viz. spinning around a collection of non-blocking functions. Ironically, the machine library includes a POLL_HOOK function which is used by asyncio - however running up the asyncio learning curve is a high price to pay for a simple requirement. Given that the rx_any function has been provided for a non-blocking UART receive, it seems a bizarre oversight not to have provided the equivalent function for UART transmit.
Code Size
No response
Implementation
I hope the MicroPython maintainers or community will implement this feature
Code of Conduct
Yes, I agree