Files
aqhomecontrol/avr/common/watchdog.asm
Martin Preuss f806cf30e5 Revert "added ifdefs guards for includes."
This reverts commit 15199a17a5.
2025-04-21 00:46:57 +02:00

49 lines
1.1 KiB
NASM

; ***************************************************************************
; 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. *
; ***************************************************************************
; ***************************************************************************
; code
.cseg
watchdogOn:
ldi r16, (1<<WDE) | (1<<WDP0) ; about 32ms period
out WDTCSR, r16
ldi r16, (1<<WDP0) ; about 32ms period
out WDTCSR, r16
ori r16, (1<<WDE)
out WDTCSR, r16
ret
watchdogOff:
wdr ; reset WDT
ldi r16, (0<<WDRF) ; clear WDRF bit in MCUSR
out MCUSR, r16
in r16, WDTCSR
ori r16, (1<<WDCE)|(1<<WDE)
push r15
in r15, SREG
cli
out WDTCSR, r16
ldi r16, (0<<WDE) ; Turn off WDT
out WDTCSR, r16
out SREG, r15
pop r15
ret