Skip to content

Commit

Permalink
ds1302: fix code for ccz80 version
Browse files Browse the repository at this point in the history
Sort out masks, save BC as it's a register variable now
  • Loading branch information
EtchedPixels committed Oct 18, 2023
1 parent cd67e1a commit 8b9f325
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 20 additions & 4 deletions Kernel/dev/ds1302_commonu.s
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,38 @@ _ds1302_set_driven:
pop hl
push hl
push de
ld b, l ; load argument
push bc
ld a, (_rtc_shadow)
and >PIN_DATA_HIZ ; 0 - output pin
bit 0, b ; test bit
bit 0, l ; test bit
jr nz, writereg
or <PIN_DATA_HIZ
jr writereg

_ds1302_set_data:
pop de
pop hl
push hl
push de
push bc
ld bc, PIN_DATA_OUT
jr setpin

_ds1302_set_ce:
pop de
pop hl
push hl
push de
push bc
ld bc, PIN_CE
jr setpin

_ds1302_set_clk:
pop de
pop hl
push hl
push de
push bc
ld bc, PIN_CLK
jr setpin

Expand All @@ -54,14 +69,15 @@ setpin:
pop hl
push hl
push de
push bc
ld a, (_rtc_shadow) ; load current register contents
and b ; unset the pin
ld b, l ; load argument from caller (fastcall)
bit 0, b ; test bit
bit 0, l ; test bit
jr z, writereg ; arg is false
or c ; arg is true
writereg:
ld bc, (_rtc_port)
out (c), a ; write out new register contents
ld (_rtc_shadow), a ; update our shadow copy
pop bc
ret
2 changes: 1 addition & 1 deletion Kernel/dev/ds1302_rcbusu.S
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.code

#define PIN_CE 0xEF10
#define PIN_DATA_HIZ 0xCF20
#define PIN_DATA_HIZ 0xDF20
#define PIN_CLK 0xBF40
#define PIN_DATA_OUT 0x7F80
#define PIN_DATA_IN 0x01
Expand Down

0 comments on commit 8b9f325

Please sign in to comment.