avr: cleanup handling of apps and modules in devices/all

This commit is contained in:
Martin Preuss
2026-03-16 21:37:46 +01:00
parent dbb004234f
commit 5c18f5bf9a
22 changed files with 1452 additions and 982 deletions

View File

@@ -1,5 +1,5 @@
; ***************************************************************************
; copyright : (C) 2025 by Martin Preuss
; copyright : (C) 2026 by Martin Preuss
; email : martin@libchipcard.de
;
; ***************************************************************************
@@ -7,130 +7,24 @@
; * Please see toplevel file COPYING of that project for license details. *
; ***************************************************************************
; ***************************************************************************
; code
#ifndef AQH_AVR_DEVICES_ALL_APPS_ASM
#define AQH_AVR_DEVICES_ALL_APPS_ASM
.cseg
.include "devices/all/apps_init.asm"
.include "devices/all/apps_run.asm"
.include "devices/all/apps_msg.asm"
; ---------------------------------------------------------------------------
; @routine initApps
;
; Call init functions of the used apps. Add your routine calls here.
initApps:
#ifdef APPS_NETWORK
ldi yl, LOW(netInterfaceData)
ldi yh, HIGH(netInterfaceData)
bigcall AppNetwork_Init
#ifdef MODULES_CLOCK
.include "devices/all/apps_100ms.asm"
.include "devices/all/apps_1s.asm"
.include "devices/all/apps_1m.asm"
.include "devices/all/apps_1h.asm"
.include "devices/all/apps_1d.asm"
#endif
#ifdef APPS_ROUTER
bigcall AppRouter_Init
#endif
#ifdef APPS_HUB
bigcall AppHub_Init
#endif
#ifdef APPS_FORWARDER
bigcall AppForwarder_Init
#endif
#ifdef APPS_MOTION
bigcall AppMotion_Init
#endif
#ifdef APPS_DOOR
bigcall AppDoor_Init
#endif
#ifdef APPS_REPORTSENSORS
bigcall AppReportSensors_Init
#endif
#ifdef APPS_STATS
bigcall AppStats_Init
#endif
#ifdef APPS_MA_LIGHT
bigcall AppMotionLight_Init
#endif
; done
ret
; @end
; ---------------------------------------------------------------------------
; @routine runApps
;
; Call run functions of the used modules. Add your routine calls here.
;
runApps:
clr r16
#ifdef APPS_ROUTER
push r16
bigcall AppRouter_Run
pop r16
sbci r16, 0 ; decrease r16 only if CFLAG set
#endif
#ifdef APPS_HUB
push r16
bigcall AppHub_Run
pop r16
sbci r16, 0 ; decrease r16 only if CFLAG set
#endif
#ifdef APPS_FORWARDER
push r16
bigcall AppForwarder_Run
pop r16
sbci r16, 0 ; decrease r16 only if CFLAG set
#endif
; add more modules here
tst r16
clc
breq runApps_end
sec
runApps_end:
ret
; @end
; ---------------------------------------------------------------------------
; @routine mainAppsOnPacketReceived
;
; Let all apps handle received message.
mainAppsOnPacketReceived:
#ifdef APPS_NETWORK
; handle messages
ldi yl, LOW(netInterfaceData)
ldi yh, HIGH(netInterfaceData)
bigcall AppNetwork_HandleMsg
#endif
#ifdef APPS_MA_LIGHT
bigcall AppMotionLight_OnPacketReceived
#endif
; add more here
ret
; @end