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