📄 test.lst
字号:
ARM COMPILER V0.07, test 26/11/04 11:06:08 PAGE 1
ARM COMPILER V0.07, COMPILATION OF MODULE test
OBJECT MODULE PLACED IN test.OBJ
COMPILER INVOKED BY: C:\KEIL\ARM\BIN\CA.EXE test.c TABS(4)
stmt level source
1 // Copyright (c) 2001-2003 Rowley Associates Limited.
2 //
3 // This file may be distributed under the terms of the License Agreement
4 // provided with this software.
5 //
6 // THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE
7 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
8 //
9 ////////////////////////////////////////////////////////////////////////////////
10
11 #include "lpc210x.h"
12 #include <inttypes.h>
13 #include <string.h>
14 #include "lcd.h"
15 #include "uart.h"
16 #include "intgrt.h"
17 #include "i2c.h"
18
19
20
21
22
23
24 #define LEDMASK 0x1000
25 #define RELAYMASK 0x2000
26
27 //BUTTONS
28
29 #define BUTTON1 0x08000000 //P0.27
30 #define BUTTON2 0x10000000 //P0.28
31 #define BUTTON3 0x20000000 //P0.29
32 #define BUTTON4 0x40000000 //P0.30
33 #define BUTTON5 0x80000000 //P0.31
34
35
36
37 #define SECONDS 0x02 // define Real Time Clock register addresses
38 #define MINUTE 0x03
39 #define HOUR 0x04
40 #define DAY 0x05
41 #define WEEKDAY 0x06
42 #define MONTH 0x07
43 #define YEAR 0x08
44
45 #define NOMASK 0 // define constants to indicate if a register should be masked
-
46 #define MASK 1 // or not after reading
47
48 enum weekdays { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY,
49 FRIDAY, SATURDAY }; // define the weekdays
50
51 enum months { JANUARY = 1, FEBRUARY, MARCH, APRIL, MAY, JUNE,
52 JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER };
53 // define the months
54
55 struct time // define a structure to store
56 { // date and time in
57 unsigned char seconds;
58 unsigned char minute;
ARM COMPILER V0.07, test 26/11/04 11:06:08 PAGE 2
59 unsigned char hour;
60 unsigned char day;
61 unsigned char weekday;
62 unsigned char month;
63 unsigned int year;
64 };
65
66 struct time current_time = {0, 56, 9, 13, MONDAY, MARCH, 00};
67 // declare a structure to hold
68 // the current time
69
70 // function prototypes
71 unsigned char store_time(struct time *t);
72 unsigned char read_time(struct time *t);
73 void display_time(struct time *t);
74
75
76 // function store_time
77 // stores time and date in the Real Time Clock
78 // passed is a pointer to a time structure containing the time and date to store
79 // returned is a 1 for success, a 0 for failiure
80 unsigned char store_time(struct time *t)
81 {
82 1 WriteRTC(SECONDS, t->seconds); // store the seconds in the 'seconds' register
83 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
84 1 WriteRTC(MINUTE, t->minute); // store the minutes in the 'minute' register
85 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
86 1 WriteRTC(HOUR, t->hour); // store the hour in the 'hour' register
87 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
88 1 WriteRTC(DAY, t->day); // store the day in the 'day' register
89 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
90 1 WriteRTC(WEEKDAY, t->weekday); // store the weekday in the 'weekday' register
91 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
92 1 WriteRTC(MONTH, t->month); // store the month in the 'month' register
93 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
94 1 WriteRTC(YEAR, t->year); // store the year in the 'year' register
95 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
96 1 return 1;
97 1 }
98
99 // function read_time
100 // obtains the current time and date from the Real Time Clock
101 // passed is the pointer to a time structure to store the date and time in
102 // returned is a 1 for success, a 0 for failiure
103 unsigned char read_time(struct time *t)
104 {
105 1 t->seconds = ReadRTC(SECONDS, MASK); // read the seconds and mask off unused bits in the 'seconds' re
-gister
106 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
107 1 t->minute = ReadRTC(MINUTE, MASK); // read the minutes and mask off unused bits in the 'minutes' re
-gister
108 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
109 1 t->hour = ReadRTC(HOUR, MASK); // read the hour and mask off unused bits in the 'hour' register
110 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
111 1 t->day = ReadRTC(DAY, MASK); // read the day and mask off unused bits in the 'day' register
112 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
113 1 t->weekday = ReadRTC(WEEKDAY, MASK); // read the weekday and mask off unused bits in the 'weekday' re
-gister
114 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
115 1 t->month = ReadRTC(MONTH, MASK); // read the month and mask off unused bits in the 'month' regist
-er
116 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
117 1 t->year = ReadRTC(YEAR, MASK); // read the year and mask off unused bits in the 'year' register
118 1 // if (i2c_status == I2C_ERROR) return 0; // check for an error
119 1 return 1;
120 1 }
ARM COMPILER V0.07, test 26/11/04 11:06:08 PAGE 3
121
122 // function display_time
123 // displays the current date and time via the UART
124 // passed is the pointer to a time structure holding the date and time to display
125 // nothing is returned
126 void display_time(struct time *t)
127 { char disp_lsb;
128 1 char disp_msb;
129 1 char start_disp_posx=0;
130 1 char start_disp_posy=0;
131 1 // printf(t->hour, t->minute, t->seconds, t->day, t->month, t->year);
132 1
133 1 disp_lsb=((t->hour) & 0x0f)+0x30;
134 1 disp_msb=(((t->hour) & 0xf0) >>4)+0x30;
135 1 lcd_gotoxy(start_disp_posx,start_disp_posy);
136 1 lcd_print(&disp_msb);
137 1 lcd_gotoxy(start_disp_posx+1,start_disp_posy);
138 1 lcd_print(&disp_lsb);
139 1
140 1 lcd_gotoxy(start_disp_posx+2,start_disp_posy);
141 1 lcd_print(":");
142 1
143 1
144 1 disp_lsb=((t->minute) & 0x0f)+0x30;
145 1 disp_msb=(((t->minute) & 0xf0) >>4)+0x30;
146 1 lcd_gotoxy(start_disp_posx+3,start_disp_posy);
147 1 lcd_print(&disp_msb);
148 1 lcd_gotoxy(start_disp_posx+4,start_disp_posy);
149 1 lcd_print(&disp_lsb);
150 1
151 1 lcd_gotoxy(start_disp_posx+5,start_disp_posy);
152 1 lcd_print(":");
153 1
154 1 disp_lsb=((t->seconds) & 0x0f)+0x30;
155 1 disp_msb=(((t->seconds) & 0xf0) >>4)+0x30;
156 1 lcd_gotoxy(start_disp_posx+6,start_disp_posy);
157 1 lcd_print(&disp_msb);
158 1 lcd_gotoxy(start_disp_posx+7,start_disp_posy);
159 1 lcd_print(&disp_lsb);
160 1
161 1 }
162
163
164 void display_date(struct time *t)
165 { char disp_lsb;
166 1 char disp_msb;
167 1 char start_disp_posx=9;
168 1 char start_disp_posy=0;
169 1 // printf(t->hour, t->minute, t->seconds, t->day, t->month, t->year);
170 1
171 1 disp_lsb=((t->day) & 0x0f)+0x30;
172 1 disp_msb=(((t->day) & 0xf0) >>4)+0x30;
173 1 lcd_gotoxy(start_disp_posx,start_disp_posy);
174 1 lcd_print(&disp_msb);
175 1 lcd_gotoxy(start_disp_posx+1,start_disp_posy);
176 1 lcd_print(&disp_lsb);
177 1
178 1 lcd_gotoxy(start_disp_posx+2,start_disp_posy);
179 1 lcd_print("/");
180 1
181 1
182 1 disp_lsb=((t->month) & 0x0f)+0x30;
183 1 disp_msb=(((t->month) & 0xf0) >>4)+0x30;
184 1 lcd_gotoxy(start_disp_posx+3,start_disp_posy);
185 1 lcd_print(&disp_msb);
186 1 lcd_gotoxy(start_disp_posx+4,start_disp_posy);
ARM COMPILER V0.07, test 26/11/04 11:06:08 PAGE 4
187 1 lcd_print(&disp_lsb);
188 1
189 1 lcd_gotoxy(start_disp_posx+5,start_disp_posy);
190 1 lcd_print("/");
191 1
192 1 disp_lsb=((t->year) & 0x0f)+0x30;
193 1 disp_msb=(((t->year) & 0xf0) >>4)+0x30;
194 1 lcd_gotoxy(start_disp_posx+6,start_disp_posy);
195 1 lcd_print(&disp_msb);
196 1 lcd_gotoxy(start_disp_posx+7,start_disp_posy);
197 1 lcd_print(&disp_lsb);
198 1
199 1 }
200
201 extern void init_serial_1 (void); /* Initialize Serial Interface */
202 extern int putchar_1 (int ch); /* Write character to Serial Port */
203 extern int getchar_1 (void); /* Read character from Serial Port */
204
205 extern void init_serial_0 (void); /* Initialize Serial Interface */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -