📄 e2prom.inc
字号:
;==============================eeprom=============================
InitEEPROM: ; add 2000.6.7
seb p5_scl ;init as 1 output; p5m_scl p5m_sda init
seb p5_sda
seb p5m_scl ;init as output mode
seb p5m_sda
seb p5_scl ;p52 p53 init p52=SCL p53=SDA,init as 1 output
seb p5_sda
;if [port2] & 01000111B != [M_KeyStopVal]
[bzifread]=1 ;must read
[e2enwrite]=0 ;disable eeprom write
[e2readtimes]=0
;endif
RTS
;===============================================================
;this is an philip pca8581 eeprom read-write subroutine
;p52:SCl p53:SDA
;===============================================================
e2processsub:
if [bzifread]==1
NOP
JSR eepromread
NOP
JSR e2rifdataereasub
NOP
JSR Fun_Remote
NOP
JSR e2ifreadsub
else
if [e2enwrite]==1
[e2enwrite]=0
NOP
JSR e2wdatasub
NOP
JSR eepromwrite
if [eepromwrite_error]==1
[eepromwrite_error]=0 ;erea,so write again
[e2enwrite]=1
endif
endif
endif
NOP
RTS
;************************************
;
;************************************
e2ifreadsub:
[e2readtimes]=++[e2readtimes]
if [e2readtimes]!=5
if [readonepage_error]==1
[bzifread]=1
else
[bzifread]=0
endif
else
[e2readtimes]=0
[bzifread]=0 ;not read
endif
NOP
RTS
;************************************
;
;************************************
e2rifdataereasub:
lif [e2rdata0]==0a5h && [e2rdata7]==0a5h
[e2_dataerea]=0
if [e2rdata1] == [e2rdata4]
[m_ir1mode] = [e2rdata1]
if [ir1_onoff] == 1
[CompStopSecond] = 00h
[CompStopMinute] = 00h
endif
else
[e2_dataerea]=1
endif
if [e2rdata2] == [e2rdata5]
[m_ir1fantem] = [e2rdata2]
[ir1_sleep] = 0 ;20041030
else
[e2_dataerea]=1
endif
if [e2rdata3] == [e2rdata6]
if [b_hrp] == 1 ;2005-11-5 19:12
[m_ir1else] = [e2rdata3]
[ir1Round_U] = 0
if [ir1light_hrp] == 1
[ir1_light] = 1
else
[ir1_light] = 0
endif
else
IF [e2rdata3] == 0FFH
[ir1_light] = 1
else
[ir1_light] = 0
endif
endif
else
[e2_dataerea]=1
endif
;SEB b_remamflag ; chen
[m_ir1TimerOff] = 00H
[m_ir1TimerOnOff] = 00H
[m_ir1TimerOn] = 00H
[m_ir1ClockHigh] = 00H
[m_ir1ClockLow] = 00H
JSR FunExec_KeyPower
else
[e2_dataerea]=1
endif
RTS
;************************************
;
;************************************
;e2rgetdatasub:
;if [e2_dataerea]==0
;[m_ir1fantem]=[e2rdata1]
;[ir1_sleep]=0
;[m_ir1mode]=[e2rdata2]&00001111b
;[m_ir1else]=[e2rdata2]&00110000b ;air
;if [e2r_light]==1
;[ir1_light]=1
;else
;[ir1_light]=0
;endif
;if [e2r_duster]==1
[ir1_duster]=1
;else
[ir1_duster]=0
;endif
;[irflag]=1
;if [ir1_onoff]==1 ;990814
;[en_test]=0 ;disable test 990813
;endif
;JSR Fun_Remote
; endif
; RTS
;====================================
;
;====================================
eepromread:
clt
cld
jsr eepromstart
ldm #10100000b,onebyteregister ;slave address
jsr writeonebyte
bbs writeonebyte_error,eepromread020
ldm #00h,onebyteregister ;word address
jsr writeonebyte
bbs writeonebyte_error,eepromread020
jsr eepromstart
ldm #10100001b,onebyteregister ;slave address
jsr writeonebyte
bbs writeonebyte_error,eepromread020
ldx #0h
eepromread010:
jsr readonebyte
sta ronepageaddress,x
clb p5_scl
nop
seb p5m_sda
clb p5_sda
nop
nop
nop
nop
nop
seb p5_scl
nop
nop
nop
nop
nop
inx
cpx #7h
bne eepromread010
jsr readonebyte
sta ronepageaddress,x
clb p5_scl
nop
seb p5m_sda
clb p5_sda
jsr eepromstop
clb readonepage_error
rts
eepromread020:
clb writeonebyte_error
seb readonepage_error
rts
;====================================
readonebyte:
clt
cld
ldy #08h
readonebyte010:
clb p5_scl
nop
clb p5m_sda
nop
nop
seb p5_scl
nop
nop
nop
sec
bbs p5_sda,readonebyte020
clc
readonebyte020:
rol a
dey
bne readonebyte010
clb p5_scl
rts
;************************************
;
;************************************
e2wdatasub:
[e2w_3mincom0]=0
[e2wdata0]=0a5h
[e2wdata1] = [m_ir1mode]
[e2wdata2] = [m_ir1fantem]
if [b_hrp] == 1 ;2005-11-5 19:20
[e2wdata3] = [m_ir1else]
else
if [ir1_light] == 1
[e2wdata3] = 0FFH
else
[e2wdata3]= 00h;[m_ir1else]
endif
endif
[e2wdata4]= [e2wdata1]
[e2wdata5]= [e2wdata2]
[e2wdata6]= [e2wdata3]
[e2wdata7]=0a5h
NOP
RTS
;====================================
;
;==================================== ;
eepromwrite: ;
clt ;
cld ;
jsr eepromstart ;start condition
;
ldm #10100000b,onebyteregister ;slave address
jsr writeonebyte
bbs writeonebyte_error,eepromw010
ldm #00h,onebyteregister ;word address
jsr writeonebyte
bbs writeonebyte_error,eepromw010
jsr writeonepage ;data writed
bbs writeonepage_error,eepromw010
jsr eepromstop ;stop condition
clb eepromwrite_error
rts
eepromw010:
seb eepromwrite_error
jsr eepromstop
rts
;====================================
writeonepage:
clt
cld
ldx #00h
wopage010:
lda wonepageaddress,x
sta onebyteregister
txa
pha
jsr writeonebyte
pla
tax
bbs writeonebyte_error,wopage020
inx
txa
cmp #08h
bne wopage010
clb writeonepage_error
rts
wopage020:
seb writeonepage_error
clb writeonebyte_error
rts
;====================================
eepromstart:
clt
cld
seb p5m_scl
seb p5m_sda
nop
seb p5_scl
nop
seb p5_sda
nop
nop
nop
clb p5_sda
nop
nop
nop
nop
nop
clb p5_scl
nop
rts
;====================================
eepromstop:
clt
cld
seb p5_scl
nop
nop
nop
nop
nop
seb p5_sda
nop
rts
;====================================
writeonebyte:
clt
cld
seb p5m_sda
ldx #08h
lda onebyteregister
wobyte010:
asl a
bcc wobyte020
seb p5_sda
bra wobyte030
wobyte020:
clb p5_sda
wobyte030:
nop
nop
nop
nop
nop
seb p5_scl
nop
nop
nop
nop
nop
clb p5_scl
dex
bne wobyte010
;==================================== ;check the acknowledge code
clb p5m_sda ;set the port as input mode
nop
seb p5_scl
nop
nop
nop
nop
nop
bbs p5_sda,wobyte040
nop
seb p5m_sda
clb p5_scl
rts
wobyte040:
seb writeonebyte_error
seb p5m_sda
clb p5_scl
rts
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -