com2w: added some recovery code, improved protocol.

after sending a byte wait for the same time when sending the last bit as
with the other bits (otherwise the last bit might get lost by slower
devices).
This commit is contained in:
Martin Preuss
2025-08-20 23:27:17 +02:00
parent 6a3f6be8a9
commit 3a7951be16
2 changed files with 44 additions and 14 deletions

View File

@@ -12,9 +12,8 @@
.equ COM2W_WAITTIME1 = 17000
.equ COM2W_WAITTIME2 = 10000
.equ COM2W_WAITTIME1 = 25000
.equ COM2W_WAITTIME2 = 15000
@@ -206,7 +205,7 @@ com2wSendByte:
ldi r17, 8
com2wSendByte_loop:
rcall com2wClkSetLow
rcall com2wWaitTime2 ; shorter wait period (R22)
rcall com2wWaitTime2 ; shorter wait period (R22)
lsr r16
brcs com2wSendByte_send1
rcall com2wDataSetLow
@@ -214,11 +213,13 @@ com2wSendByte_loop:
com2wSendByte_send1:
rcall com2wDataSetHigh
com2wSendByte_sent:
Utils_WaitNanoSecs 5000, 0, r22 ; wait for very short time to ensure data is stable when clock rises
Utils_WaitNanoSecs 5000, 0, r22 ; wait for very short time to ensure data is stable when clock rises
rcall com2wClkSetHigh
rcall com2wWaitTime2 ; shorter wait period (R22)
rcall com2wWaitTime2 ; shorter wait period (R22)
dec r17
brne com2wSendByte_loop
rcall com2wWaitTime2 ; shorter wait period (R22)
rcall com2wDataSetHigh
ret
; @end