+void uart0_init(void) {
+
+ PINSEL0=0x05; // pin select -> tx, rx
+ UART0_FCR=0x07; // enable fifo
+ UART0_LCR=0x83; // set dlab + word length
+ //UART0_DLL=0x10; // br: 9600 @ 10/4 mhz
+ UART0_DLL=0x04; // br: 38400 @ 10/4 mhz
+ UART0_DLM=0x00;
+ UART0_LCR=0x03; // unset dlab
+}
+
+void uart0_send_string(char *txbuf) {
+
+ int i;
+
+ i=0;
+
+ while(txbuf[i]) {
+ UART0_THR=txbuf[i++];
+ /* flush if tx buffer maximum reached */
+ if(!(i%16))
+ while(!(UART0_LSR&(1<<6)))
+ continue;
+ }
+
+ /* flush if \n and \r do not fit in the tx buffer */
+ if(i>14)
+ while(!(UART0_LSR&(1<<6)))
+ continue;
+
+ UART0_THR='\n';
+ UART0_THR='\r';
+
+ /* flush uart0 anyways */
+ while(!(UART0_LSR&(1<<6)))
+ continue;
+}