📄 uart.c
字号:
#include "uart.h"
void init_uart()
{
/* Set GPI0 for UART */
GPHCON = 0x16faaa;
GPHDAT = 0x0;
GPHUP = 0x07ff;
/* Initialize UART */
ULCON0 = 0x03; // 8 bits, no parity, one stop bit
UCON0 = 0x05; // interrupt request or polling mode
UFCON0 = 0x00; // no FIFO
UMCON0 = 0x00; // no flow control
UBRDIV0 = (50000000 / (115200 * 16))-1; // boud-rate 115200
}
int isempty()
{
return !(UTRSTAT0 & 1);
}
int isfull()
{
return !(UTRSTAT0 & (1<<2));
}
char sio_getchar()
{
while (isempty());
return URXH0;
}
void sio_putchar(char c)
{
if (c == '\n') {
while (isfull());
UTXH0 = '\r';
}
while (isfull());
UTXH0 = c;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -