61 lines
972 B
ArmAsm
61 lines
972 B
ArmAsm
; system-independent 1-Wire routines
|
|
|
|
.export _1wire_writebit
|
|
.export _1wire_writebyte
|
|
.export _1wire_readbit
|
|
.export _1wire_readbyte
|
|
.export _1wire_reset
|
|
|
|
; provided by system-specific routines at link time
|
|
|
|
.import _1wire_send1_impl
|
|
.import _1wire_send0_impl
|
|
.import _1wire_read_impl
|
|
.import _1wire_reset_impl
|
|
|
|
; some system-specific routines can be passed through
|
|
|
|
_1wire_send1 := _1wire_send1_impl
|
|
_1wire_send0 := _1wire_send0_impl
|
|
_1wire_reset := _1wire_reset_impl
|
|
|
|
; read a bit from the 1-Wire bus
|
|
|
|
_1wire_readbit:
|
|
jsr _1wire_read_impl
|
|
ldx #0
|
|
rts
|
|
|
|
; write a bit to the 1-Wire bus
|
|
|
|
_1wire_writebit:
|
|
ror ;shift out of LSB
|
|
bcs :+
|
|
jmp _1wire_send0
|
|
: jmp _1wire_send1
|
|
|
|
; write a byte to the 1-Wire bus
|
|
|
|
_1wire_writebyte:
|
|
ldx #8
|
|
: pha ;LSB is written first
|
|
jsr _1wire_writebit
|
|
pla
|
|
ror ;shift bit just sent out
|
|
dex
|
|
bne :-
|
|
rts
|
|
|
|
; read a byte from the 1-Wire bus
|
|
|
|
_1wire_readbyte:
|
|
ldx #8
|
|
: pha
|
|
jsr _1wire_read_impl
|
|
ror
|
|
pla
|
|
ror
|
|
dex
|
|
bne :-
|
|
rts
|