avr: wait for free CLK line on error when in flash mode
This commit is contained in:
@@ -270,7 +270,7 @@ com2wRecvMsg_loop:
|
|||||||
rjmp com2wRecvMsg_end
|
rjmp com2wRecvMsg_end
|
||||||
com2wRecvMsg_eBadSize:
|
com2wRecvMsg_eBadSize:
|
||||||
com2wRecvMsg_eIo:
|
com2wRecvMsg_eIo:
|
||||||
com2wRecvMsg_clcRet:
|
rcall com2wRecvByteWaitForQuietClk ; (r18, r20, r22)
|
||||||
clc
|
clc
|
||||||
com2wRecvMsg_end:
|
com2wRecvMsg_end:
|
||||||
ret
|
ret
|
||||||
@@ -278,6 +278,32 @@ com2wRecvMsg_end:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine com2wRecvByteWaitForQuietClk
|
||||||
|
;
|
||||||
|
; Wait until the clock line is consistently high for 1ms.
|
||||||
|
;
|
||||||
|
; @clobbers r18, r20, r22
|
||||||
|
|
||||||
|
com2wRecvByteWaitForQuietClk:
|
||||||
|
ldi r18, 200
|
||||||
|
com2wRecvByteWaitForQuietClk_loop:
|
||||||
|
ldi r20, 100 ; wait up to 1ms for clock high (R20, R22)
|
||||||
|
rcall com2wWaitForClockLowMulti10Us
|
||||||
|
brcs com2wRecvByteWaitForQuietClk_waitForLow
|
||||||
|
dec r18
|
||||||
|
brne com2wRecvByteWaitForQuietClk_loop
|
||||||
|
rjmp com2wRecvByteWaitForQuietClk_ret
|
||||||
|
com2wRecvByteWaitForQuietClk_waitForLow:
|
||||||
|
ldi r20, 100 ; wait up to 1ms for clock low (R20, R22)
|
||||||
|
rcall com2wWaitForClockLowMulti10Us
|
||||||
|
brcc com2wRecvByteWaitForQuietClk_ret ; not low within 1ms, assume line is quiet
|
||||||
|
brne com2wRecvByteWaitForQuietClk_loop
|
||||||
|
com2wRecvByteWaitForQuietClk_ret:
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine com2wRecvByte
|
; @routine com2wRecvByte
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user