?? serial.c
字號:
#include <types.h>#define FCR_COM1_BASE 0x1f004090#define FCR_COM1_DATA (FCR_COM1_BASE + 0x0)#define FCR_COM1_FCR (FCR_COM1_BASE + 0x2)#define FCR_COM1_LSR (FCR_COM1_BASE + 0x5)#define UART_SET(idx, value) KSEG1_STORE8(FCR_COM1_BASE + idx, value)#define UART_GET(idx) KSEG1_LOAD8(FCR_COM1_BASE + idx)static u8 init = 0;void init_serial(){ UART_SET(0x3, 0x80); /* LCR, set DLAB = 1 */ UART_SET(0x0, 0x6c); /* Crystal:16.6MHz, Baudrate = 9600bps ->0x6C */ UART_SET(0x1, 0x00); /* Baudrate=9600. MSB should be 0 */ UART_SET(0x3, 0x0b); /* 8N1 */ UART_SET(0x2, 0x47); /* RCVR Trigger & FIFO Enable */}void serial_putc(u8 c){ u32 counter = 0x1000; if (!init) { init_serial(); init = 1; } while ((counter--) && !(UART_GET(0x5) & 0x20)); if (counter) UART_SET(0x0,c);}void serial_puts(u8 *buf){ u8 *p = NULL; for (p = buf; *p != 0; p++) serial_putc(*p);}void serial_put32(u32 value){ char buf[11]; buf[0] = '0'; buf[1] = 'x'; ctx(buf + 2, (value >> 24) & 0xff); ctx(buf + 4, (value >> 16) & 0xff); ctx(buf + 6, (value >> 8) & 0xff); ctx(buf + 8, value & 0xff); buf[10] = 0; serial_puts(buf);}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -