UART block until all data is sent
I need to synchronize sending some data on a UART to some other events. I therefore need to know when the UART have completed sending all data in the SW buffer. I am using the regular UART in Quartus 13.1 and the regular altera_avalon_uart_driver for Nios II. How can I make a call that will block until the data is sent or get an interrupt when it is sent?
Here are some things I have tried.
I have tried opening the UART with fopen, sending data with fputs and waiting for all data to be sent with fflush. fflush returned almost immediately and long before all data was sent so fflush did not work for this purpose. I have also tried different types of buffering with setvbub. I have tried different variations of the open and write functions. I see there is a function called tcdrain that is supposed to, from my understanding, wait until all data is sent. It is actually just a macro # define tcdrain(fd) _ioctl (fd, _TCSBRK, 1). But it does not link since it can not find _ioctl. I have tried using ioctl (fd, _TCSBRK, 1) but it did not wait until the data was sent.
Hi,
May be you can try to access these uart core control register bits for interrupt. Can refer to this manual (page 145).
Best Regards
Sheng
p/s: If any answer from community or Intel support are helpful, please feel free to mark as solution and give Kudos.