Files
aqhomecontrol/avr/modules/triggeractor/main.asm
Martin Preuss 88a66f6822 avr: add complex fan controller app with base classes to be used by other apps as well.
- add modules
  - holdtimer (keep actor running while triggered)
  - triggeraction (connect actor with holdtimer)
- add app fan_controller
  - uses the modules mentioned above to turn on/off fans in connection
    with e.g. motion sensor nodes
2026-08-06 00:05:50 +02:00

116 lines
2.8 KiB
NASM

; ***************************************************************************
; copyright : (C) 2026 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 AQH_AVR_MODULES_TRIGGERACTOR_MAIN_ASM
#define AQH_AVR_MODULES_TRIGGERACTOR_MAIN_ASM
; ---------------------------------------------------------------------------
; @routine TCA_Init @global
;
; @param Z pointer to data in FLASH (byte address for lpm!)
TCA_Init:
; let base class init
bigcall HTIM_Init ; (any, !Z)
bigcall HTIM_Start
bigcall HTIM_EnableActor
ret
; @end
; ---------------------------------------------------------------------------
; @routine TCA_OnEveryTick
;
; @param Z pointer to data in FLASH (byte address for lpm!)
; @param Y pointer to data in RAM
TCA_OnEveryTick:
ldd r17, Y+HTIM_RAM_OFFS_FLAGS
mov r16, r17
cbr r17, (1<<TCA_FLAGBITS_NEED_TRIGGER) | (1<<TCA_FLAGBITS_NEED_DISABLE) | (1<<TCA_FLAGBITS_NEED_ENABLE)
std Y+HTIM_RAM_OFFS_FLAGS, r17
push r16
sbrc r16, TCA_FLAGBITS_NEED_ENABLE
bigcall HTIM_EnableActor
pop r16
push r16
sbrc r16, TCA_FLAGBITS_NEED_DISABLE
bigcall HTIM_DisableActor
pop r16
push r16
sbrc r16, TCA_FLAGBITS_NEED_TRIGGER
bigcall HTIM_Trigger
pop r16
bigcall HTIM_OnEveryTick
ret
; @end
; ---------------------------------------------------------------------------
; @routine TCA_ReadEepromAt
;
; @param Z pointer to data in FLASH (byte address for lpm!)
; @param Y pointer to data in RAM
; @param X EEPROM address
; @return X EEPROM address after the data handled by this routine
; @clobbers r16, r17
TCA_ReadEepromAt:
bigcall HTIM_ReadEepromAt ; (r16, r17)
push yl
push yh
adiw yh:yl, TCA_RAM_OFFS_BEGIN
ldi r17, (TCA_EE_SIZE-TCA_EE_OFFS_BEGIN)
bigcall Eeprom_ReadBytes ; (r16, r17, X, Y)
pop yh
pop yl
ret
; @end
; ---------------------------------------------------------------------------
; @routine TCA_WriteEepromAt
;
; @param Z pointer to data in FLASH (byte address for lpm!)
; @param Y pointer to data in RAM
; @param X EEPROM address
; @return X EEPROM address after the data handled by this routine
; @clobbers r16, r17, r18
TCA_WriteEepromAt:
bigcall HTIM_WriteEepromAt ; (r16, r17, r18)
push yl
push yh
adiw yh:yl, TCA_RAM_OFFS_BEGIN
ldi r17, (TCA_EE_SIZE-TCA_EE_OFFS_BEGIN)
bigcall Eeprom_WriteBytes ; (r16, r17, r18, X, Y)
pop yh
pop yl
ret
; @end
#endif