Files
aqhomecontrol/avr/common/debug.asm
2025-04-21 00:33:52 +02:00

87 lines
1.6 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. *
; ***************************************************************************
#ifndef COMMON_DEBUG_H
#define COMMON_DEBUG_H
.cseg
DEBUG1:
ldi r19, 50
ldi r20, 1
ldi r21, 9
rcall blinkLed
rjmp DEBUG1
DEBUG2:
ldi r19, 50
ldi r20, 1
ldi r21, 1
rcall blinkLed
rjmp DEBUG2
; @param r19 loop count
; @param r20 on time
; @param r21 off time
; @clobbers (R16, R18, R22, R24, R25)
blinkLed:
cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on
mov r22, r20
rcall waitForMultiple100ms ; (R252
sbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; off
mov r22, r21
rcall waitForMultiple100ms ; (R22)
dec r19
brne blinkLed
ret
; @param r22 number of 100ms periods to wait
waitForMultiple100ms:
waitForMultiple100ms_loop:
push r22
rcall waitFor100ms
pop r22
dec r22
brne waitForMultiple100ms_loop
ret
waitFor100ms:
ldi r22, 10
waitFor100ms_loop:
push r22
rcall waitFor10ms
pop r22
dec r22
brne waitFor100ms_loop
ret
waitFor10ms:
ldi r22, 100
waitFor10ms_loop:
push r22
rcall Utils_WaitFor100MicroSecs
pop r22
dec r22
brne waitFor10ms_loop
ret
#endif ; COMMON_DEBUG_H