Files
aqhomecontrol/avr/modules/flash/io_attn.asm
Martin Preuss 0165b02310 flashing older nodes across t03 now works!
older nodes need the new bootloader which doesn't depend on pagesize because
those older nodes used quite large message sizes which are not supported
across t03 nodes (we would need to much RAM on t03 for this).
2025-03-23 22:40:34 +01:00

94 lines
2.5 KiB
NASM

; ***************************************************************************
; 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 ioWaitForAttnState100ms
;
; @param r16 expected state (0x00 or 0xff)
; @param r17 time to wait for expected state (in 100 ms units)
; @clobbers R17 (R22, R24)
ioWaitForAttnState100ms:
cbi COM_ATTN_DDR, COM_ATTN_PIN ; set ATTN port as input
cbi COM_ATTN_OUTPUT, COM_ATTN_PIN ; disable internal pullup for ATTN
ioWaitForAttnState100ms_loop:
push r17
ldi r17, 100
rcall ioWaitForAttnStateMilliSeconds ; (R22, R24)
pop r17
brcs ioWaitForAttnState100ms_stateReached
dec r17
brne ioWaitForAttnState100ms_loop
clc
ioWaitForAttnState100ms_stateReached:
ret
; @end
; ---------------------------------------------------------------------------
; @routine ioWaitForAttnStateMilliSeconds
;
; @param r16 expected state (0x00 or 0xff)
; @param r17 time to wait for expected state (in milliseconds)
; @clobbers R17 (R22, R24)
ioWaitForAttnStateMilliSeconds:
ioWaitForAttnStateMilliSeconds_loop:
rcall ioWaitForAttnState1ms ; (R22, R24)
brcs ioWaitForAttnStateMilliSeconds_stateReached
dec r17
brne ioWaitForAttnStateMilliSeconds_loop
clc
ioWaitForAttnStateMilliSeconds_stateReached:
ret
; @end
; ---------------------------------------------------------------------------
; @routine ioWaitForAttnState1ms
;
; 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)
ioWaitForAttnState1ms:
ldi r24, 100
ioWaitForAttnState1ms_loop:
push r17
in r17, COM_ATTN_INPUT
eor r17, r16
andi r17, (1<<COM_ATTN_PIN)
pop r17
breq ioWaitForAttnState1ms_stateReached
rcall Utils_WaitFor10MicroSecs ; wait for 10us (R22)
dec r24
brne ioWaitForAttnState1ms_loop
clc
ret
ioWaitForAttnState1ms_stateReached:
sec
ret
; @end