-
- /* 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;
-}
-
-void uart0_send_buf16(u16 *buf,int len) {
-
- int i;
-
- i=0;
-
- for(i=0;i<len/2;i++) {
- if(!(i%8))
- while(!(UART0_LSR&(1<<6)))
- continue;
- UART0_THR=buf[i]&0xff;
- UART0_THR=(buf[i]>>8)&0xff;
- }
-}
-
-void uart0_send_buf32(u32 *buf,int len) {
-
- int i;
-
- i=0;
-
- for(i=0;i<len/4;i++) {
- if(!(i%4))
- while(!(UART0_LSR&(1<<6)))
- continue;
- UART0_THR=buf[i]&0xff;
- UART0_THR=(buf[i]>>8)&0xff;
- UART0_THR=(buf[i]>>16)&0xff;
- UART0_THR=(buf[i]>>24)&0xff;
- }
-}
-
-void uart0_send_byte(u8 send) {
-
- while(!(UART0_LSR&(1<<5)))
- continue;
-
- UART0_THR=send;
-}
-
-u8 uart0_get_byte(void) {
-
- u8 rx;
-
- while(!(UART0_LSR&(1<<0)))
- continue;
-
- rx=UART0_RBR;
-
- return rx;
-}
-
-/*
- * main function
- */
-
-int main() {
-
- char buf="betty - live from the flash at 0x80000000! ;)\r\n";
-
- pll_init();
- uart0_init();
- ext_mem_bank_init();
- pin_select_init();
-
- while(1)
- uart0_send_string(buf);