4 * author: hackbard@hackdaworld.org
14 void uart0_init(void) {
16 /* configure uart 0 */
17 UART0_FCR=0x07; // enable fifo
18 UART0_LCR=0x83; // set dlab + word length
19 UART0_DLL=0x04; // br: 115200
21 UART0_LCR=0x03; // unset dlab
24 void uart0_send_string(char *txbuf) {
32 /* flush if tx buffer maximum reached */
34 while(!(UART0_LSR&(1<<6)))
38 /* flush uart0 anyways */
39 while(!(UART0_LSR&(1<<6)))
43 void uart0_send_buf16(u16 *buf,int len) {
49 for(i=0;i<len/2;i++) {
51 while(!(UART0_LSR&(1<<6)))
53 UART0_THR=buf[i]&0xff;
54 UART0_THR=(buf[i]>>8)&0xff;
58 void uart0_send_buf32(u32 *buf,int len) {
64 for(i=0;i<len/4;i++) {
66 while(!(UART0_LSR&(1<<6)))
68 UART0_THR=buf[i]&0xff;
69 UART0_THR=(buf[i]>>8)&0xff;
70 UART0_THR=(buf[i]>>16)&0xff;
71 UART0_THR=(buf[i]>>24)&0xff;
75 void uart0_send_byte(u8 send) {
77 while(!(UART0_LSR&(1<<5)))
83 u8 uart0_get_byte(void) {
87 while(!(UART0_LSR&(1<<0)))