Tx UART in polling API non blocking

Hello 

I am using UART to communicate with an other micrcontroller. To handle well the communication between both, before sending a frame I am positionning an IO to 1 and after the end of the transmition I am pulling it back to 0.


My code is looking like that : 

Where the funtion "send_data_via_uart1" is doing that : 

In this function, the function "uart_poll_out" should be a blocking call. Which means I should not leave this function before sending all I have to send. 

But some times I see my IO going back to 0 before the end of the transmission.

So my question is, is there any flag or semaphore indicating the end of the trnasmisison, somewhere in your driver implementation ? 


I tried to add a loop on a flag going to false when  "uart_irq_tx_complete" = 1 in my uart1 callback : 

With tx_irq enable it makes my application being stuck in uart1 callback.

And with tx_irq disable it does not reach my flag.

After all that I still can't catch the end of my transmission.

Note that I am using UART without Easy DMA but I saw in nRF52840 datahseet that only UARTE has a TXSTOPPED event. And I am using UART polling API and not Async API.

Best regards

Thibaud

Related