📄 serial.lst
字号:
ARM COMPILER V0.07, serial 26/11/04 11:06:08 PAGE 1
ARM COMPILER V0.07, COMPILATION OF MODULE serial
OBJECT MODULE PLACED IN serial.OBJ
COMPILER INVOKED BY: C:\KEIL\ARM\BIN\CA.EXE serial.c TABS(4)
stmt level source
1 /******************************************************************************/
2 /* This file is part of the uVision/ARM development tools */
3 /* Copyright KEIL ELEKTRONIK GmbH 2002-2004 */
4 /******************************************************************************/
5 /* */
6 /* SERIAL.C: Low Level Serial Routines */
7 /* */
8 /******************************************************************************/
9
10 //#include <LPC21xx.H> /* LPC21xx definitions */
11 #include "lpc210x.h"
12 #define CR 0x0D
13
14
15 void init_serial_1 (void) { /* Initialize Serial Interface */
16 1 PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */
17 1 UART1_LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
18 1 UART1_DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
19 1 UART1_LCR = 0x03; /* DLAB = 0 */
20 1 }
21
22
23 int putchar_1 (int ch) { /* Write character to Serial Port */
24 1
25 1 if (ch == '\n') {
26 2 while (!(UART1_LSR & 0x20));
27 2 UART1_THR = CR; /* output CR */
28 2 }
29 1 while (!(UART1_LSR & 0x20));
30 1 return (UART1_THR = ch);
31 1 }
32
33
34 int getchar_1 (void) { /* Read character from Serial Port */
35 1
36 1 while (!(UART1_LSR & 0x01));
37 1
38 1 return (UART1_RBR);
39 1 }
40
41 // ****************************
42
43
44 void init_serial_0 (void) { /* Initialize Serial Interface */
45 1 PINSEL0 = 0x00000005; /* Enable RxD0 and TxD0 */
46 1 UART0_LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
47 1 UART0_DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
48 1 UART0_LCR = 0x03; /* DLAB = 0 */
49 1
50 1
51 1 // defines
52 1
53 1 // UART_BAUD calculates a division rate given a baud rate
54 1 // for use with uart0Init() and uart1Init()
55 1 // example: uart0Init(UART_BAUD(115200), UART_8N1, UART_FIFO_8);
56 1 //
57 1 // BEWARE: additional code will be generated if 'baud' is not a contant
58 1 //#define UART_BAUD(baud) (uint16_t)((PCLK+baud*8L)/(baud*16))
59 1
ARM COMPILER V0.07, serial 26/11/04 11:06:08 PAGE 2
60 1
61 1
62 1 // set the baudrate
63 1 // U0LCR = ULCR_DLAB_ENABLE; // select divisor latches
64 1 // U0DLL = (uint8_t)baud; // set for baud low byte
65 1 // U0DLM = (uint8_t)(baud >> 8); // set for baud high byte
66 1
67 1
68 1
69 1
70 1 }
71
72
73 int putchar_0 (int ch) { /* Write character to Serial Port */
74 1
75 1 if (ch == '\n') {
76 2 while (!(UART0_LSR & 0x20));
77 2 UART0_THR = CR; /* output CR */
78 2 }
79 1 while (!(UART0_LSR & 0x20));
80 1 return (UART0_THR = ch);
81 1 }
82
83
84 int getchar_0 (void) { /* Read character from Serial Port */
85 1
86 1 while (!(UART0_LSR & 0x01));
87 1
88 1 return (UART0_RBR);
89 1 }
ARM COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -