avr: use new code in latest nodes.
This commit is contained in:
126
avr/devices/all/main.asm
Normal file
126
avr/devices/all/main.asm
Normal file
@@ -0,0 +1,126 @@
|
||||
; ***************************************************************************
|
||||
; 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. *
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine main @global
|
||||
|
||||
main:
|
||||
cli
|
||||
; setup stack
|
||||
.ifdef SPH ; if SPH is defined
|
||||
ldi r16, High(RAMEND)
|
||||
out SPH, r16 ; init MSB stack pointer
|
||||
.endif
|
||||
ldi r16, Low(RAMEND)
|
||||
out SPL, r16 ; init LSB stack pointer
|
||||
|
||||
; rcall watchdogOff ; turn off watchdog timer (sometimes it stays on after reboot)
|
||||
|
||||
rcall systemSetSpeed
|
||||
rcall systemInitHardware
|
||||
rcall Utils_Init
|
||||
rcall Utils_SetupUid
|
||||
rcall initModules
|
||||
rcall initApps
|
||||
rcall Utils_InitialWait
|
||||
sei ; Enable interrupts
|
||||
|
||||
rcall onSystemStart
|
||||
|
||||
#ifdef MODULES_LED
|
||||
ldi xl, LOW(blinkPattern) ; debug: set blink pattern
|
||||
ldi xh, HIGH(blinkPattern)
|
||||
ldi zl, LOW(ledA3Flash)
|
||||
ldi zh, HIGH(ledA3Flash)
|
||||
ldi yl, LOW(ledA3Sram)
|
||||
ldi yh, HIGH(ledA3Sram)
|
||||
rcall Led_SetPattern
|
||||
#endif
|
||||
|
||||
main_loop:
|
||||
rcall runModules
|
||||
rcall runApps
|
||||
|
||||
#ifdef MODULES_NETWORK
|
||||
rcall handleMessages
|
||||
#endif
|
||||
|
||||
; only modify SE, SM1 and SM0
|
||||
cli
|
||||
in r16, MCUCR
|
||||
ldi r17, (1<<SE) | (1<<SM1) | (1<<SM0)
|
||||
neg r17
|
||||
and r16, r17
|
||||
ori r16, (1<<SE) ; sleep mode "idle", enable
|
||||
out MCUCR, r16
|
||||
sei ; make sure interrupts really are enabled
|
||||
sleep ; sleep, wait for interrupt
|
||||
rjmp main_loop
|
||||
|
||||
main_loop_reboot:
|
||||
cli
|
||||
rjmp BOOTLOADER_ADDR
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine onSystemTimerTick
|
||||
;
|
||||
; Called every 100ms. No arguments, no results.
|
||||
|
||||
onSystemTimerTick:
|
||||
rcall onEvery100ms
|
||||
|
||||
#ifdef MODULES_CLOCK
|
||||
rcall Clock_Every100ms ; generates calls to onEverySecond/Minute/Hour/Day
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_LED_SIMPLE
|
||||
rcall LedSimple_Every100ms
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_UART_BITBANG
|
||||
rcall UART_BitBang_Every100ms
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_TCRT1000
|
||||
rcall TCRT1K_Every100ms
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef APPS_NETWORK
|
||||
ldi yl, LOW(netInterfaceData)
|
||||
ldi yh, HIGH(netInterfaceData)
|
||||
rcall AppNetwork_Every100ms
|
||||
#endif
|
||||
|
||||
#ifdef APPS_MOTION
|
||||
rcall AppMotion_Every100ms
|
||||
#endif
|
||||
|
||||
#ifdef APPS_DOOR
|
||||
rcall AppDoor_Every100ms
|
||||
#endif
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user