avr/modules/flash: make protocol more robust

- wait for ATTN high after error receiving a packet
- use different wait times when waiting for FLASH_START and FLASH_DATA
This commit is contained in:
Martin Preuss
2025-05-05 21:05:07 +02:00
parent 9063962c7d
commit eecb022a0c
4 changed files with 13 additions and 5 deletions

View File

@@ -48,6 +48,7 @@ checkFlash:
rcall ioRawSendMsg ; (r16, r17, X)
ldi r16, NETMSG_CMD_FLASH_START
ldi r20, FLASH_WAITFORSTART_TRIES
rcall ioWaitForGivenMsg ; (r16, r17, r18, r19, r20, r22, X)
brcc checkFlash_end
@@ -59,8 +60,8 @@ checkFlash:
ldi xl, LOW(flashRecvBuffer)
ldi xh, HIGH(flashRecvBuffer)
rcall flashProcessHandleFlashStart
brcc checkFlash_end
sec
; brcc checkFlash_end
; sec
checkFlash_end:
ret
; @end
@@ -80,6 +81,7 @@ flashProcess:
flashProcess_loop1:
; wait up to 10s for incoming FLASH_DATA message
ldi r16, NETMSG_CMD_FLASH_DATA
ldi r20, FLASH_WAITFORDATA_TRIES
rcall ioWaitForGivenMsg ; (r16, r17, r18, r19, r20, r22, X)
brcc flashProcess_end ; no FLASH_DATA or FLASH_END msg
; either FLASH_DATA or FLASH_END received
@@ -186,7 +188,7 @@ flashProcessHandleFlashData_sendResponse:
pop r16
#endif
ldi r24, 50
ldi r24, 25
rcall flashWaitForMillisecs ; (R22, R24)
rcall flashProcessSendFlashResponse ; (R16, R17, R18, R19, R20, X)
sbi LED_PIN, LED_PINNUM ; toggle