diff --git a/avr/common/0BUILD b/avr/common/0BUILD index 963fbf8..d4e91ba 100644 --- a/avr/common/0BUILD +++ b/avr/common/0BUILD @@ -14,6 +14,7 @@ utils.asm utils_copy_from_flash.asm utils_copy_sdram.asm + utils_initial_wait.asm utils_wait.asm utils_wait_fixed.asm utils_wait_pin.asm diff --git a/avr/common/utils_initial_wait.asm b/avr/common/utils_initial_wait.asm new file mode 100644 index 0000000..31c9a97 --- /dev/null +++ b/avr/common/utils_initial_wait.asm @@ -0,0 +1,41 @@ +; *************************************************************************** +; 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 +