4 * author: hackbard@hackdaworld.org
14 void uart0_init(void) {
16 /* select pins 0.0 and 0.1 as tx and rx */
17 PINSEL0=(PINSEL0&~(0xf))|0x05;
19 /* configure uart 0 */
20 UART0_FCR=0x07; // enable fifo
21 UART0_LCR=0x83; // set dlab + word length
22 UART0_DLL=0x04; // br: 115200
24 UART0_LCR=0x03; // unset dlab
27 void uart0_send_string(char *txbuf) {
35 /* flush if tx buffer maximum reached */
37 while(!(UART0_LSR&(1<<6)))
41 /* flush uart0 anyways */
42 while(!(UART0_LSR&(1<<6)))
46 void uart0_send_buf16(u16 *buf,int len) {
52 for(i=0;i<len/2;i++) {
54 while(!(UART0_LSR&(1<<6)))
56 UART0_THR=buf[i]&0xff;
57 UART0_THR=(buf[i]>>8)&0xff;
61 void uart0_send_buf32(u32 *buf,int len) {
67 for(i=0;i<len/4;i++) {
69 while(!(UART0_LSR&(1<<6)))
71 UART0_THR=buf[i]&0xff;
72 UART0_THR=(buf[i]>>8)&0xff;
73 UART0_THR=(buf[i]>>16)&0xff;
74 UART0_THR=(buf[i]>>24)&0xff;
78 void uart0_send_byte(u8 send) {
80 while(!(UART0_LSR&(1<<5)))
86 u8 uart0_get_byte(void) {
90 while(!(UART0_LSR&(1<<0)))