What I have observed is that if this function is preempted/interrupted for a substantial length of time at the wrong time, an overrun can still occur in the Rx FIFO which causes the function to get stuck in an endless loop and never return. I believe the problem is that the rxFifoMaxBytes value is initialize improperly for bytesPerFrame values less than 4.
This value is currently set in SDK 2.7 as follows:
uint32_t rxFifoMaxBytes = 4U * fifoSize;
I believe it should instead take bytesPerFrame into consideration. Something like:
uint32_t rxFifoMaxBytes = ((bytesPerFrame <= 4U) ? bytesPerFrame : 4U) * fifoSize;
In my case, I was using a bits per frame setting of 8 (so my bytesPerFrame is 1), and observed the same lockup as before. After putting in the proposed fix, the lockup no longer occurs.
Thanks for sharing your feedback.
There is a bug fix for this issue in SDK 2.8.0_EVKB-IMXRT1050, which will be released later this month.