📄 serial.c
字号:
/******************************************************************************/
/* This file is part of the uVision/ARM development tools */
/* Copyright KEIL ELEKTRONIK GmbH 2002-2004 */
/******************************************************************************/
/* */
/* SERIAL.C: Low Level Serial Routines */
/* */
/******************************************************************************/
#include <LPC21xx.H> /* LPC21xx definitions */
#define CR 0x0D
void init_serial (void) { /* Initialize Serial Interface */
PINSEL0 &= ~(0x0F << 0);
PINSEL0 |= (0x05 << 0);// 设置I/O连接到UART0 P0.0 P0.1
// PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U0DLL = 0x08; /* 115200 Baud Rate @ 15MHz VPB Clock */
U0LCR = 0x03; /* DLAB = 0 */
}
int putchar1 (int ch) { /* Write character to Serial Port */
if (ch == '\n') {
while (!(U0LSR & 0x20));
U0THR = CR; /* output CR */
}
while (!(U0LSR & 0x20));
return (U0THR = ch);
}
int getkey (void) { /* Read character from Serial Port */
if (U0LSR & 0x01)
{
return (U0RBR);
} else {
return 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -