| Purpose: | Wait until the COM1 Transmit Buffer and the USART Data Register are both completely empty before returning to the caller. |
| Assumes: | Nothing. |
| Passed: | Nothing. |
| Returns: | Nothing. |
| Alters: | Nothing; even SREG (the FLAGs BYTE) is preserved. |
| Example: |
|
| Test it: | This is a little more elaborate example and setup, but it has a very useful routine with some interesting features: |
|
| Notes: | The Operating System handles the COM1 Transmit buffering as a circular FIFO queue. It updates bCOM1TxHeadPtr as characters are enbuffered and bCOM1TxTailPtr as they are transmitted out the COM1 serial port (i.e., placed in UDR0, the USART Data Register.) |
| This system function checks waits until the tail pointer reaches the head pointer. It also verifies that the UDRE0 BIT in Register UCSR0A is clear to verify that the last BYTE transmitted has completely cleared the USART. | |
| It holds in a tight loop, not allowing any additional BYTE to be written to the COM1 Transmit Buffer. This includes the background data output system function. | |
| If interrupts were not enabled upon calling this function, they are enabled while in it and disabled again (i.e., SREG restored) upon exiting it. | |
| With interrupts enabled, characters can still be received into the COM1 Receive buffer and the system clock timer update, for example, along with any other interrupt-based process. | |
| Dropin: (setup code) |
; Setup for the COM1_WaitForTxEmpty() call: ; Passed: Nothing. ; Returns: Nothing. ; Alters: Nothing. |
| Also see: | The COM1 Transmit Status group of System Functions and the Command Extensions. |