void USART_Write(AT91S_USART *usart, unsigned short data, volatile unsigned int timeOut) { if (timeOut == 0) { while ((usart->US_CSR & AT91C_US_TXEMPTY) == 0); } else { while ((usart->US_CSR & AT91C_US_TXEMPTY) == 0) { if (timeOut == 0) { TRACE_ERROR("USART_Write: Timed out.\n\r"); return; } timeOut--; } } usart->US_THR = data; }