+typedef unsigned char u8;
+
+void uart0_init(int br) {
+
+ PINSEL0&=~((0x03<<0)|(0x03<<2)); // clear bits 0-3
+ PINSEL0|=((1<<0)|(1<<2)); // pin select: tx, rx
+
+ UART0_LCR|=(1<<7); // enable access to divisor
+ UART0_DLL=(P_CLOCK/(br*16))&0xff; // set divisor
+ UART0_DLL=((P_CLOCK/(br*16))&0xff00)>>8;
+ UART0_LCR&=~(1<<7); // disable access to divisor
+
+ UART0_LCR&=~(0x03<<2); // 1 stop bit, no parity
+ UART0_LCR|=0x03; // 8 data bits
+
+ UART0_FCR=0x01; // activate fifo