SCLK EQU P1.0
IO EQU P1.1
REST EQU P1.2
ht1380_out:
MOV R7,#8
ShiftOut:
RRC A
MOV IO,C
SETB SCLK
CLR SCLK
DJNZ R7,ShiftOut
RET
ht1380_in:
SETB IO
MOV R7,#8
ShiftIn:
MOV C,IO
RRC A
SETB SCLK
CLR SCLK
DJNZ R7,ShiftIn
RET
read_ht1380:
CLR SCLK
CLR REST
SETB REST
ACALL ht1380_out
ACALL ht1380_in
CLR REST
SETB SCLK
RET
write_ht1380:
CLR SCLK
CLR REST
SETB REST
ACALL ht1380_out
MOV A,B
ACALL ht1380_out
CLR REST
SETB SCLK
RET
; ***********************************
; Sample code
; ***********************************
; ***** unprotect
MOV A,#$8E
MOV B,#0
ACALL write_ht1380
; ***** start
MOV A,#$80
MOV B,#0
ACALL write_ht1380
; ***** Protect
MOV A,#$8E
MOV B,#$80
ACALL write_ht1380
...
...
...