main.asm: CLI while measuring and preparing packet. Directly call onSystemStart.

This commit is contained in:
Martin Preuss
2023-02-06 21:55:10 +01:00
parent 7e3dfa12fa
commit 4d4bdf3203
2 changed files with 39 additions and 49 deletions

View File

@@ -15,6 +15,9 @@ main:
rcall initModules rcall initModules
sei ; Enable interrupts sei ; Enable interrupts
rcall onSystemStart
ldi xl, LOW(blinkPattern) ; debug: set blink pattern ldi xl, LOW(blinkPattern) ; debug: set blink pattern
ldi xh, HIGH(blinkPattern) ldi xh, HIGH(blinkPattern)
ldi zl, LOW(ledA3Flash) ldi zl, LOW(ledA3Flash)
@@ -245,6 +248,9 @@ printSendStats:
#ifdef MODULES_COM #ifdef MODULES_COM
Main_SendValueMsg: Main_SendValueMsg:
in r15, SREG
push r15
cli
lds r16, comAddress ; do we have an address assigned? lds r16, comAddress ; do we have an address assigned?
tst r16 tst r16
breq sendValueMsg_done ; no, do nothing breq sendValueMsg_done ; no, do nothing
@@ -278,6 +284,8 @@ sendValueMsg_checkHum:
rcall CPRO_EnqueueValue rcall CPRO_EnqueueValue
pop r22 pop r22
sendValueMsg_done: sendValueMsg_done:
pop r15
out SREG, r15
ret ret
#endif #endif
#endif #endif

View File

@@ -6,8 +6,6 @@
.equ TIMER_FLAGS_100MS = 1 .equ TIMER_FLAGS_100MS = 1
.equ TIMER_FLAGS_1S = 2 .equ TIMER_FLAGS_1S = 2
.equ TIMER_STATE_SYSSTART = 8 ; onSysStart was already called
@@ -19,7 +17,6 @@
timerModuleData: timerModuleData:
timerModuleTickCounter: .byte 1 ; only low byte used timerModuleTickCounter: .byte 1 ; only low byte used
timerModuleFlags: .byte 1 timerModuleFlags: .byte 1
timerModuleState: .byte 1
timerModuleCounter10s: .byte 1 timerModuleCounter10s: .byte 1
timerModuleCounter1m: .byte 1 timerModuleCounter1m: .byte 1
timerModuleCounterSecs: .byte 4 timerModuleCounterSecs: .byte 4
@@ -100,25 +97,10 @@ Timer_Fini:
Timer_Run: Timer_Run:
in r15, SREG in r15, SREG
cli cli
lds r18, timerModuleState
mov r16, r18 ; r18: state
ori r16, TIMER_STATE_SYSSTART
sts timerModuleState, r16
lds r17, timerModuleFlags lds r17, timerModuleFlags
clr r16 clr r16
sts timerModuleFlags, r16 sts timerModuleFlags, r16
out SREG, r15 ; restore global IRQ flag out SREG, r15 ; restore global IRQ flag
; call onSystemStart when first run
mov r16, r18
andi r16, TIMER_STATE_SYSSTART
brne Timer_Run_check100
push r17
rcall onSystemStart
pop r17
Timer_Run_check100:
mov r16, r17 mov r16, r17
andi r16, TIMER_FLAGS_100MS andi r16, TIMER_FLAGS_100MS
breq Timer_Run_l1 breq Timer_Run_l1