Fix Reset/Writing to DS1216E in //c

This commit is contained in:
Rémy GIBERT 2016-02-21 21:43:53 +01:00
parent 361f14050e
commit ae69cb3097

View File

@ -46,31 +46,33 @@ CS.INIT ldy #S.PS.hARGS
lda (pPs),y
bne CS.INIT.SET
CS.INIT.READ jsr NSC.Select
CS.INIT.READ jsr NSC.Init
jsr NSC.Read
ldx #7
lda DS1216E.DATA
.1 and DS1216E.DATA,x
.1 lda DS1216E.DETECT,x
eor DS1216E.DATA,x
bne .8
dex
bne .1
cmp #$FF
bne .2
bpl .1
>LDYA L.MSG.READ.KO
>SYSCALL SYS.PSTROutYA
bra .8
.2 jsr NSC.Dump
lda #DEVMGR.ERRNOHW
sec
rts
.8 jsr NSC.Dump
>LDYA L.MSG.USAGE
>SYSCALL SYS.PSTROutYA
.8 lda #0 tell TSKMGR that all done ok, but
lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
CS.INIT.SET >SYSCALL SYS.GetMemPtrA
>STYA ZPPtr1
@ -132,7 +134,6 @@ CS.INIT.SET >SYSCALL SYS.GetMemPtrA
sta DS1216E.DATA+6
stz DS1216E.DATA+7
jsr NSC.Select
jsr NSC.Write
lda #0 tell TSKMGR that all done ok, but
@ -148,10 +149,31 @@ CS.DOEVENT
CS.QUIT clc
rts
*--------------------------------------
NSC.Select php
NSC.Init php
sei
lda $CFFF
pha
ldx #7
.1 ldy #8
.2 lda $C304
lsr
ror DS1216E.DETECT,x
dey
bne .2
dex
bpl .1
pla
bmi .99
sta $CFFF
sta $C00A
.99 plp
rts
*--------------------------------------
NSC.Select sta $C300
lda $C304 Reset DS1216E comparison register with READ A2=1
@ -165,18 +187,23 @@ NSC.Select php
lsr
bcc .5
iny
.5 sta $C300,y Write Pattern bit in A0, with A2=0
.5 pha
lda $C300,y Write Pattern bit in A0, with A2=0
pla
dex
bne .4
plx
dex
bpl .3
plp
rts
*--------------------------------------
NSC.Read php
sei
lda $CFFF
pha
jsr NSC.Select
ldx #7
@ -191,11 +218,18 @@ NSC.Read php
dex
bpl .1
plp
pla
bmi .99
sta $CFFF
.99 plp
rts
*--------------------------------------
NSC.Write php
sei
lda $CFFF
pha
jsr NSC.Select
ldx #7
@ -207,18 +241,24 @@ NSC.Write php
lsr
bcc .5
iny
.5 sta $C300,y Write Pattern bit in A0, with A2=0
.5 pha
lda $C300,y Write Pattern bit in A0, with A2=0
pla
dex
bne .4
plx
dex
bpl .3
plp
pla
bmi .99
sta $CFFF
.99 plp
rts
*--------------------------------------
NSC.Dump ldx #1
ldy #1
lda DS1216E.DATA+3
bit #%00010000
beq .1
@ -328,7 +368,8 @@ MSG.READ.OK4 >PSTRING "\nTime:"
MSG.USAGE >PSTRING "\n\nTo Reset the chip and set clock, type:\nNSCUTIL DD/MM/YY hh:mm:ss\n"
TmpByte .BS 1
DS1216E.PATTERN .HS 5CA33AC55CA33AC5 Reverted 7->0
DS1216E.DATA .HS FFFFFFFFFFFFFFFF Reverted YY MM DD Day HH mm SS CS
DS1216E.DETECT .BS 8
DS1216E.DATA .BS 8 Reverted YY MM DD Day HH mm SS CS
*--------------------------------------
DS.START
DS.END