Timer: Added callback onSystemStart
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
.equ TIMER_FLAGS_100MS = 1
|
||||
.equ TIMER_FLAGS_1S = 2
|
||||
|
||||
.equ TIMER_STATE_SYSSTART = 8 ; onSysStart was already called
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +19,7 @@
|
||||
timerModuleData:
|
||||
timerModuleTickCounter: .byte 1 ; only low byte used
|
||||
timerModuleFlags: .byte 1
|
||||
timerModuleState: .byte 1
|
||||
timerModuleCounter10s: .byte 1
|
||||
timerModuleCounter1m: .byte 1
|
||||
timerModuleCounterSecs: .byte 4
|
||||
@@ -97,10 +100,25 @@ Timer_Fini:
|
||||
Timer_Run:
|
||||
in r15, SREG
|
||||
cli
|
||||
clr r16
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user