Replace multiple wait macros with calls (saves 10 bytes).

This commit is contained in:
Martin Preuss
2024-09-01 20:06:05 +02:00
parent 6aac577365
commit 65e60c2dec
2 changed files with 32 additions and 4 deletions

View File

@@ -167,7 +167,7 @@ com2WaitForDataState1ms_loop:
eor r22, r16
andi r22, (1<<COM_PINNUM_DATA)
breq com2WaitForDataState1ms_stateReached
Utils_WaitNanoSecs 10000, 0, r22 ; wait for 10us
rcall com2WaitFor10MicroSecs ; wait for 10us (R22)
dec r17
brne com2WaitForDataState1ms_loop
clc
@@ -195,7 +195,7 @@ com2WaitForAttnState1ms_loop:
eor r22, r16
andi r22, (1<<COM_PINNUM_ATTN)
breq com2WaitForAttnState1ms_stateReached
Utils_WaitNanoSecs 10000, 0, r22 ; wait for 10us
rcall com2WaitFor10MicroSecs ; wait for 10us (R22)
dec r17
brne com2WaitForAttnState1ms_loop
clc
@@ -206,3 +206,17 @@ com2WaitForAttnState1ms_stateReached:
; ---------------------------------------------------------------------------
; wait for 10 microsecs (minus cycles for call and ret).
;
; IN:
; - nothing
; OUT:
; - nothing
; REGS: r22
com2WaitFor10MicroSecs:
Utils_WaitNanoSecs 10000, 3+4, r22 ; wait for 10us (minus RCALL and RET)
ret

View File

@@ -80,7 +80,7 @@ COM2_SendPacketWithAttn:
push r15
in r15, SREG
cli
Utils_WaitNanoSecs COM_BIT_LENGTH, 0, r22 ; wait for one bit duration
rcall com2WaitForOneBitLength ; wait for one bit duration (R22)
; check for ATTN line: busy?
cbi COM_PORT_ATTN, COM_PINNUM_ATTN ; disable pullup on ATTN
cbi COM_DDR_ATTN, COM_PINNUM_ATTN ; set ATTN as input
@@ -90,7 +90,7 @@ COM2_SendPacketWithAttn:
cbi COM_PORT_ATTN, COM_PINNUM_ATTN ; set ATTN low
sbi COM_DDR_ATTN, COM_PINNUM_ATTN ; set ATTN as output
Utils_WaitNanoSecs COM_BIT_LENGTH, 0, r22 ; wait for one bit duration
rcall com2WaitForOneBitLength ; wait for one bit duration (R22)
adiw xh:xl, COM2_MSG_OFFS_MSGLEN
ld r16, X
@@ -122,6 +122,20 @@ COM2_SendPacketWithAttn_retNc:
; ---------------------------------------------------------------------------
; wait for one bit length (minus cycles for call and ret).
;
; IN:
; - nothing
; OUT:
; - nothing
; REGS: r22
com2WaitForOneBitLength:
Utils_WaitNanoSecs COM_BIT_LENGTH, 3+4, r22 ; wait for one bit duration (minus RCALL/RET)
ret
; ---------------------------------------------------------------------------
; send packet over wire, expects ATTN to be low.
;