; *************************************************************************** ; copyright : (C) 2024 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 ; --------------------------------------------------------------------------- ; main ; 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 Utils_SetupUid rcall initModules rcall 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 ; sbi DDRA, PORTA2 ; debug ; sbi PINA, PORTA2 ; debug (toggle) ; cbi PORTA, PORTA2 ; debug (on) ; sbi PORTA, PORTA2 ; debug (off) ; ldi r16, 1 ; sts twiMasterScanEnabled, r16 main_loop: rcall runModules ; only modify SE, SM1 and SM0 cli in r16, MCUCR ldi r17, (1<