avr: some formatting.

This commit is contained in:
Martin Preuss
2023-04-09 18:50:09 +02:00
parent 0600a2d9ab
commit 55ba84d74a

View File

@@ -30,7 +30,7 @@ timerModuleTickCounter: .byte 1
timerModuleFlags: .byte 1
timerModuleCounterSecs: .byte 4
timerModuleDerivedCounters: .byte 10 ; must correspond to entries in timer table!
timerModuleDerivedCounters: .byte 10 ; size must be number of entries in timer table
timerModuleData_end:
@@ -47,11 +47,11 @@ TIMER_BEGIN:
; number of entries here must be equal to bytes in timerModuleDerivedCounters!
timerTable:
.db 5, 0, LOW(onEvery5s), HIGH(onEvery5s) ; 5s : overflow after 5*1s (1)
.db 5, 0, LOW(onEvery5s), HIGH(onEvery5s) ; 5s: overflow after 5*1s (1)
.db 2, 0, LOW(onEvery10s), HIGH(onEvery10s) ; 10s: overflow after 2*5s (2)
.db 3, 0, LOW(onEvery30s), HIGH(onEvery30s) ; 30s: overflow after 3*10s (3)
.db 2, 0, LOW(onEvery1m), HIGH(onEvery1m) ; 1m : overflow after 2*30s (4)
.db 5, 0, LOW(onEvery5m), HIGH(onEvery5m) ; 5m : overflow after 5*1m (5)
.db 2, 0, LOW(onEvery1m), HIGH(onEvery1m) ; 1m: overflow after 2*30s (4)
.db 5, 0, LOW(onEvery5m), HIGH(onEvery5m) ; 5m: overflow after 5*1m (5)
.db 3, 0, LOW(onEvery15m), HIGH(onEvery15m) ; 15m: overflow after 3*5m (6)
.db 2, 0, LOW(onEvery30m), HIGH(onEvery30m) ; 30m: overflow after 2*15m (7)
.db 2, 0, LOW(onEvery1h), HIGH(onEvery1h) ; 1h: overflow after 2*30m (8)
@@ -70,7 +70,7 @@ timerTable:
; - nothing
; USED: r16, r17, x
Timer_Init: ; setup timer for 15.2588 interrupts per second (e.g. every 65.5 ms)
Timer_Init: ; setup timer for IRQ every 100ms
; reset data in SDRAM
ldi xh, HIGH(timerModuleData)
ldi xl, LOW(timerModuleData)
@@ -153,7 +153,7 @@ Timer_Run_1s_passed:
; ---------------------------------------------------------------------------
; Increment cascading timer counters.
; Increment cascading timer counters. Called once every second.
;
; This routine starts with the first cascaded counter and increments it.
; If that counter value does not overflow (according to timer table entry) then
@@ -217,8 +217,8 @@ timerIncrementCounters_done:
timerCallFirstOnEveryHandlers:
push r16
rcall onEvery100ms ; always call this one
rcall onEverySecond ; and this
rcall onEvery100ms ; always call this one
rcall onEverySecond ; and this
pop r16
tst r16
@@ -226,27 +226,20 @@ timerCallFirstOnEveryHandlers:
ldi zl, LOW(timerTable*2)
ldi zh, HIGH(timerTable*2)
ldi xl, LOW(timerModuleDerivedCounters) ; points to first counter: timerModuleCounterFor10s
ldi xh, HIGH(timerModuleDerivedCounters)
timerCallFirstOnEveryHandlers_loop:
lpm r17, Z ; overflow value
tst r17 ; 0?
breq timerCallFirstOnEveryHandlers_done ; yes: end of list
adiw zh:zl, 2 ; skip to handler address
lpm r20, Z+ ; read handler address
lpm r17, Z ; overflow value
tst r17 ; 0?
breq timerCallFirstOnEveryHandlers_done ; yes: end of list
adiw zh:zl, 2 ; skip to handler address
lpm r20, Z+ ; read handler address
lpm r21, Z+
push r16 ; call handler
push xl
push xh
push zl
push zh
ld r16, X+ ; current counter value
rcall timerCallR21R20
pop zh
pop zl
pop xh
pop xl
push r16 ; call handler
push zl
push zh
rcall timerCallR21R20
pop zh
pop zl
pop r16
dec r16
brne timerCallFirstOnEveryHandlers_loop