Files
aqhomecontrol/avr/common/utils_initial_wait.asm
2025-04-29 00:34:53 +02:00

42 lines
1.2 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. *
; ***************************************************************************
; ---------------------------------------------------------------------------
; @routine Utils_InitialWait
;
; Initial wait to desync nodes.
;
; This routine waits for between 10 to 2560 milliseconds (derived from UID)
;
; @clobbers r16, r17, r18, r19, r20, r21, r22, X
Utils_InitialWait:
; setup initial wait loop
rcall Utils_ReadUid ; (R16, X)
clr r16
eor r16, r18
eor r16, r19
eor r16, r20
eor r16, r21
Utils_InitialWait_l1: ; wait R16 x 10 milliseconds
ldi r17, 200
Utils_InitialWait_l2: ; wait for 10ms
rcall Utils_WaitFor50MicroSecs ; (R22)
dec r17
brne Utils_InitialWait_l2
dec r16
brne Utils_InitialWait_l1
ret
; @end