Hi,
I've been looking at the "transfer" API for LPUART, for interrupt-based non-blocking transfers. It seems to do a decent job of wrapping all the "happy case" handling of LPUART interrupts, etc, and providing a good high level API for just receiving data when it's ready (i.e. handling IDLE, RX ready, TX complete, etc). However, it makes handling UART errors very difficult.
There is no error handling inside the LPUART_TransferHandleIRQ function, and just after that function in fsl_lpuart.c is a bogus empty LPUART_TransferHandleErrorIRQ containing a comment "To be implemented by the user". This looks completely half-baked.
The only way to actually handle UART errors seems to be to override the default LPUARTx_IRQHandler functions so that instead of calling LPUARTx_RX_DriverIRQHandler (or TX), you'd have to call your own function that handles errors and passes on "happy case" interrupts to the original LPUARTx_RX/TX_DriverIRQHandler so it can call into LPUART_TransferHandleErrorIRQ.
In addition you'd have to enable those error interrupts yourself outside the transfer API by calling LPUART_EnableInterrupts, and in your error handling also call LPUART_DisableInterrupts and deal with clearing them, etc.
This seems like a lot of extra hassle to handle errors. Why is this not baked into the transfer API itself?
-m
Hello @nxp16,
Thank you for the detailed feedback. I understand that the SDK could be a little ambiguous since these are intended to provide a common use cases for each peripheral functionality. We are constantly working to improve our APIs thanks also of recommendations like this. Thank you for the recommendations, and we hope that LPUART's error handling will be implemented in future releases.
On the other hand, could you please let me know which specific error conditions you are interested in handling and which device you are using? With that information, I can suggest documentation related to those error conditions that may help with your implementation.
BR
Habib