diff --git a/avr/common/wait_100us.asm b/avr/common/wait_100us.asm new file mode 100644 index 0000000..abfa7ec --- /dev/null +++ b/avr/common/wait_100us.asm @@ -0,0 +1,27 @@ +; *************************************************************************** +; copyright : (C) 2023 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_WaitFor100MicroSecs @global +; +; wait for about 100 microsecs. +; +; @clobbers r22 + +Utils_WaitFor100MicroSecs: + rcall Utils_WaitFor50MicroSecs + rcall Utils_WaitFor50MicroSecs + ret +; @end + + + diff --git a/avr/common/wait_10us.asm b/avr/common/wait_10us.asm new file mode 100644 index 0000000..a89e24d --- /dev/null +++ b/avr/common/wait_10us.asm @@ -0,0 +1,25 @@ +; *************************************************************************** +; copyright : (C) 2023 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_WaitFor10MicroSecs @global +; +; wait for 10 microsecs (minus cycles for call and ret). +; +; @clobbers r22 + +Utils_WaitFor10MicroSecs: + Utils_WaitNanoSecs 10000, 7, r22 ; wait for 10us (minus RCALL and RET) + ret +; @end + + diff --git a/avr/common/wait_1ms.asm b/avr/common/wait_1ms.asm new file mode 100644 index 0000000..cf876c4 --- /dev/null +++ b/avr/common/wait_1ms.asm @@ -0,0 +1,47 @@ +; *************************************************************************** +; copyright : (C) 2023 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_WaitFor1MilliSec @global +; +; wait for about 1ms. +; +; @clobbers r22 + +Utils_WaitFor1MilliSec: + push r21 + ldi r21, 10 +Utils_WaitFor1MilliSec_loop: + rcall Utils_WaitFor100MicroSecs ; (R22) + dec r21 + brne Utils_WaitFor1MilliSec_loop + pop r21 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine Utils_WaitForMilliSecs @global +; +; wait for given amount of milliseconds +; @param r16 number of millisecs to wait +; @clobbers r22 + +Utils_WaitForMilliSecs: + rcall Utils_WaitFor100MicroSecs ; (R22) + dec r16 + brne Utils_WaitForMilliSecs + ret +; @end + + diff --git a/avr/common/wait_50us.asm b/avr/common/wait_50us.asm new file mode 100644 index 0000000..33c4d41 --- /dev/null +++ b/avr/common/wait_50us.asm @@ -0,0 +1,24 @@ +; *************************************************************************** +; copyright : (C) 2023 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_WaitFor50MicroSecs @global +; +; wait for 50 microsecs (minus cycles for call and ret). +; +; @clobbers r22 + +Utils_WaitFor50MicroSecs: + Utils_WaitNanoSecs 50000, 7, r22 ; wait for 50us (minus RCALL and RET) + ret +; @end +