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 e6390a17ac
commit d3c279101c
2 changed files with 39 additions and 49 deletions

View File

@@ -6,8 +6,6 @@
.equ TIMER_FLAGS_100MS = 1
.equ TIMER_FLAGS_1S = 2
.equ TIMER_STATE_SYSSTART = 8 ; onSysStart was already called
@@ -19,7 +17,6 @@
timerModuleData:
timerModuleTickCounter: .byte 1 ; only low byte used
timerModuleFlags: .byte 1
timerModuleState: .byte 1
timerModuleCounter10s: .byte 1
timerModuleCounter1m: .byte 1
timerModuleCounterSecs: .byte 4
@@ -100,25 +97,10 @@ Timer_Fini:
Timer_Run:
in r15, SREG
cli
lds r18, timerModuleState
mov r16, r18 ; r18: state
ori r16, TIMER_STATE_SYSSTART
sts timerModuleState, r16
lds r17, timerModuleFlags
clr r16
sts timerModuleFlags, r16
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
andi r16, TIMER_FLAGS_100MS
breq Timer_Run_l1