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