avr: updated flash procedure code.

This commit is contained in:
Martin Preuss
2025-01-19 15:44:46 +01:00
parent ba279ae2bb
commit c390b1059c
12 changed files with 653 additions and 67 deletions

View File

@@ -0,0 +1,70 @@
; ***************************************************************************
; copyright : (C) 2025 by Martin Preuss
; email : martin@libchipcard.de
;
; ***************************************************************************
; * This file is part of the project "AqHome". *
; * Please see toplevel file COPYING of that project for license details. *
; ***************************************************************************
; ***************************************************************************
; code
.cseg
; ---------------------------------------------------------------------------
; @routine flashWaitForAttnState
;
; @param r16 expected state (0x00 or 0xff)
; @param r17 time to wait for expected state (in milliseconds)
; @clobbers
flashWaitForAttnState:
flashWaitForAttnState_loop:
rcall flashWaitForAttnState1ms ; (R22, R24)
brcs flashWaitForAttnState_stateReached
dec r17
brne flashWaitForAttnState_loop
clc
ret
flashWaitForAttnState_stateReached:
ret
; @end
; ---------------------------------------------------------------------------
; @routine flashWaitForAttnState1ms
;
; Wait for up to 1ms for ATTN line to reach the given state
;
; @return CFLAG set if state reached, cleared otherwise
; @param R16 expected state (0xff for high, 0 for low)
; @clobbers R24 (R22)
flashWaitForAttnState1ms:
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN port as input
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable internal pullup for ATTN
ldi r24, 100
flashWaitForAttnState1ms_loop:
push r17
in r17, COM_ATTN_INPUT
eor r17, r16
andi r17, (1<<COM_ATTN_PIN)
pop r17
breq flashWaitForAttnState1ms_stateReached
rcall Utils_WaitFor10MicroSecs ; wait for 10us (R22)
dec r24
brne flashWaitForAttnState1ms_loop
rjmp flash_recv_clc_ret
flashWaitForAttnState1ms_stateReached:
sec
ret
; @end