📄 key_display.l
字号:
Sat Jan 14 09:29:55 2006
SAM8 Assembler for Reduced Instruction Ver. 2.15T(Win32)
Copyright (c) 2003 Samsung Electronics Co.
--------------------------------------------------------------------
Source File Name : key_display.SRC
Output File Name : key_display.o
List File Name : key_display.l
1 ;key scan and led display
2
3
4 ;*****************************
5 .include "define.mac"
6 .include "S3c9454.reg"
7 ; 86C4504.REG Copyright (c) 1996 SAMSUNG ELECTRONICS CO.
8
9 .list on
10
11
12 ;*************************************************************
13 ; variable define
14 00 00 serial_data equ 00h ;74ls164 data
15 00 01 serial_clk_0 equ 01h
16 00 02 serial_clk_1 equ 02h
17
18 00 03 key_press_time equ 03h ;delay time counter 20ms
19 00 04 key_first_flag equ 04h ;if press first #01 else #00
20 00 05 key_hold_down equ 05h ;if key already hold down
21 00 06 key_value equ 06h
22 00 07 key_value_store equ 07H
23 00 08 key_delay_time1 equ 08h ;0.36S delay
24 00 09 key_delay_time2 equ 09H
25 00 0A key_press_down equ 0ah
26 00 0B key_realease_flag equ 0bh
27 00 0C key_release equ 0ch
28
29 00 10 fire_status equ 10H
30 00 11 temp_status equ 11h
31 00 12 lamp_status equ 12h
32 00 13 sound_status equ 13h
33 00 14 fire_value equ 14h
34 00 15 temp_value equ 15H
35 ;**********************************************************
36 00 12 lamp_status_dress equ 12H
37 00 13 sound_status_dress equ 13H
38 00 14 fire_value_dress equ 14H
39 00 15 temp_value_dress equ 15H
40
41 00 EF I2C_SDA0 equ 0efH ;SDA=P2.4=0 #1110 1111B
42 00 10 I2C_SDA1 equ 10H ;SDA=P2.4=1 #0001 0000B
43 00 DF I2C_SCL0 equ 0dfH ;SCL=P2.5=0 #1101 1111B
44 00 20 I2C_SCL1 equ 20H ;SCL=P2.5=1 #0010 0000B
45 00 E2 I2C_PORT equ P2
46 ;**********************************************************
47 00 16 I2C_ack_flag equ 16h
48 00 17 I2C_wrdata equ 17h
49 00 18 I2C_rddata equ 18h
50 00 19 I2C_data equ 19h
51 00 1A I2C_dress equ 1ah
52 ;***********************************************
53 00 1B led_display_flag equ 1bh ;if led display #01H else #00H
54 00 1C led_15s_time1 equ 1ch ;use to count led_sleep_time
55 00 1D led_15s_time2 equ 1dh
56 00 1E led_15s_time3 equ 1eh
57
58 00 20 motor_value equ 20h
59 00 21 motor_value_temp equ 21h
60
61 00 22 ad_hdata equ 22h
62 00 23 ad_ldata equ 23h
63
64 00 24 beep_flag equ 24h
65 00 25 beep_time1 equ 25h
66 00 26 beep_time2 equ 26h
67
68 00 30 remote_pulse_time equ 30h
69 00 31 remote_flag equ 31h
70 00 32 remote_bit_num equ 32h
71 00 33 remote_byte_num equ 33h
72 00 34 remote_data equ 34h
73 00 35 receive_end_flag equ 35h
74 00 37 remote_byte_buf0 equ 37h
75 00 38 remote_byte_buf1 equ 38h
76 00 39 remote_byte_buf2 equ 39h
77 00 40 remote_byte_buf3 equ 40h
78 00 41 remote_byte_buf4 equ 41h
79 00 42 remote_byte_buf5 equ 42h
80 00 43 remote_byte_buf6 equ 43h
81 00 44 remote_byte_buf7 equ 44h
82 00 45 remote_byte_buf8 equ 45h
83 00 46 remote_byte_buf9 equ 46h
84 00 47 remote_byte_buf10 equ 47h
85 00 48 remote_byte_buf11 equ 48h
86 00 49 remote_byte_buf12 equ 49h
87 00 4A remote_byte_buf13 equ 4ah
88 00 4B remote_byte_buf14 equ 4bh
89
90
91 ;;;;;;;;;define ram part;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
92 ;general_ram:00h-0bfh
93 ;work_register:0c0h-0cfh
94
95
96
97 ;;;;;;;;;define mac part;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
98 ;************initial stack poiter********************
99 ;this marco initials the system clock
100 ;****************************************************
101 init_clock_sp: .macro
102
103 LD CLKCON,#18H ;CPU clock frequency = fxx
104
105 LD SP,#0c0h ;00H-C0H
106
107 .endm
108
109 ;************initial ports macro*********************
110 ;this macro initial P0-P2
111 ;include use the port for I/O or special funtion
112 ;if the port need pull up
113
114 ;Port 0 Control Register:p0conl/p0conh
115
116 ;0 0 = Schmitt trigger input
117 ;0 1 = Schmitt trigger input; pull-up enable
118 ;1 0 = Push-pull output
119 ;1 1 = A/D converter input (ADC3); Schmitt trigger input off
120
121 init_port: .macro
122
123 ld p0conl,#10110101b ;p0.0 key input p0.1 remo input p0.2 RT_AD input
124 ld p0conh,#10101010b ;p0.3-p0.7 output
125 ld p1,#0ffh
126 ld p0pnd,#00000000b ;INT1 falling edge interrupt enable
127
128 ld p1con,#00001010b ;p1.0 not use,p1.1 output,reset_circuit
129
130 ld p2conl,#10101010b ;p2.3-p2.0 output 164_data 164_slk
131 ld p2conh,#01001010b ;p2.6-p2.4 output I2c_SDA I2C_SCL
132
133 ld p2,#0ffH
134
135 .endm
136
137 ;***************initial timers**************
138 ;this marco is used to initial all timers
139 ;including base timer、timer0 、watch timer
140 ;****************************************************
141
142 init_timer: .macro
143
144 ;initial timer0
145 LD T0CON,#10001000b ;timers mode 3.2MHz
146 ;Timer0 clock = fxx/8
147 ;Timer0 interrupt enable
148 LD T0DATA,#50 ;50*0.3125*8=125us
149
150 .endm
151
152 ;****************************************************
153 enable_base_time: .macro
154
155 ;initial base timer
156 LD BTCON,#0b2H ;enable watchdog timer ,Fxx/4096
157 ;Basic timer input clock=fxx/16
158 .endm
159
160 ;****************************************************
161 disable_base_time: .macro
162
163 ;initial base timer
164 LD BTCON,#0a2H ;disable watchdog timer ,Fxx/4096
165 ;Basic timer input clock=fxx/16
166 .endm
167
168
169
170
171
172
173
174 .public key_scan
175 .public led_scan
176
177 .extern WR_24C02
178 .extern RD_24C02
179 .extern restore
180
181
182 ;scan_key subroutine
183 ;**************************************************************
184 0B63 key_scan:
185
186 0B63 E6 01 F7 ld serial_clk_0,#0f7H ;74ls164 clk=P2.3 clk=0
187 0B66 E6 02 08 ld serial_clk_1,#08H ;clk=1
188
189
190 0B69 key_first_scan:
191
192 0B69 E6 00 00 ld serial_data,#00H
193 0B6C F6 0D 95 call serial_out ;serial out 00
194
195 0B6F 76 E0 01 tm p0,#01H ;test P0.0=0 ?
196 0B72 6B 18 jr z, key_operation ;if P0.0=0 to key_operation
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -