本帖最后由 dengm 于 2012-1-11 00:31 编辑
SUB_Send:
; input: A --- BYTE TO SEND
; OUTPUT: C = 0 -- 成功 C=1-- Communication Inhibited
; USE: A, PSW, R7, R6
SETB P_PS2_DATA
SETB P_PS2_CLK
MOV R7, #25 ;50us
DO_R7_1: ; WAIT 50us idel
JNB P_PS2_CLK, SEND_EX_C1
DJNZ R7, DO_R7_1
;--------------------------------
CLR P_PS2_CLK ; START BIT
MOV R7, #5
DJNZ R7, $
MOV R6, #10
MOV C, P
RRC A
DO_R6: ; DATA 8 P 1 STOP 1
MOV R7, #35 ;35 us
JNB P_PS2_CLK, SEND_EX_C1
CLR P_PS2_CLK
DJNZ R7, $
SETB P_PS2_CLK
MOV R7, #5 ; 5us
DJNZ R7, $
JNB P_PS2_CLK, SEND_EX_C1
MOV P_PS2_DATA, C
SETB C
RRC A
MOV R7, #15 ;30us
DO_R7_2:
JNB P_PS2_CLK, SEND_EX_C1
DJNZ R7, DO_R7_2
DJNZ R6, DO_R6
JNB P_PS2_CLK, SEND_EX_C1
CLR P_PS2_CLK
MOV R7, #35 ;35uS
DJNZ R7, $
CLR C
SETB P_PS2_CLK
RET
SEND_EX_C1: ;C=1-- Communication Inhibited
SETB C
SETB P_PS2_DATA
RET |