avr: reworked timer code.
Allow for more tailored timers.
This commit is contained in:
@@ -243,6 +243,12 @@
|
||||
.dseg
|
||||
|
||||
|
||||
sramTimerProtocolEverySec: .byte 2
|
||||
sramTimerEnqueueSendStats: .byte 2
|
||||
sramTimerEnqueueMemStats: .byte 2
|
||||
sramTimerEnqueueValues: .byte 2
|
||||
sramTimerSI7021Measure: .byte 2
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
@@ -256,6 +262,25 @@ blinkPattern: .db 2, 50, 0xff, 0xff ; 1 short blink, 2s pause, restart
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; timer list
|
||||
|
||||
|
||||
; TODO: add flags (IF_COM_ADDR)
|
||||
timerList:
|
||||
; SRAM variable/counter routine flags secs (0=don't start or restart)
|
||||
.dw sramTimerProtocolEverySec, CPRO_OnEverySecond, 0, 1 ; every 1s
|
||||
.dw sramTimerEnqueueSendStats, enqueueSendStats, TIMER_FLAGS_IF_ADDR, 300 ; every 5m
|
||||
.dw sramTimerEnqueueMemStats, enqueueMemStats, TIMER_FLAGS_IF_ADDR, 120 ; every 2m
|
||||
.dw sramTimerSI7021Measure, SI7021_PeriodicMeasurement, 0, 30 ; every 30s
|
||||
.dw sramTimerEnqueueValues, Main_SendValueMsg, TIMER_FLAGS_IF_ADDR, 60 ; every 1m
|
||||
.dw 0 ; end of list
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.include "main.asm"
|
||||
|
||||
|
||||
@@ -265,6 +290,7 @@ blinkPattern: .db 2, 50, 0xff, 0xff ; 1 short blink, 2s pause, restart
|
||||
onSystemStart:
|
||||
|
||||
#ifdef MODULES_COM
|
||||
; todo: setup once timer to start reclaiming address
|
||||
rcall CPRO_StartReclaimAddrProcedure
|
||||
#endif
|
||||
|
||||
@@ -272,6 +298,27 @@ onSystemStart:
|
||||
|
||||
|
||||
|
||||
#ifdef MODULES_COM
|
||||
enqueueSendStats:
|
||||
ldi r16, 0xff ; send stats to everybody
|
||||
rcall CPRO_EnqueueComSendStats
|
||||
|
||||
ldi r16, 0xff ; send stats to everybody
|
||||
rjmp CPRO_EnqueueComRecvStats
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MODULES_COM
|
||||
enqueueMemStats:
|
||||
ldi r16, 0xff ; send to everybody
|
||||
rcall CPRO_EnqueueMemStats
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 100ms. Add your routine calls here. No arguments, no results.
|
||||
|
||||
@@ -288,52 +335,6 @@ onEvery100ms:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every second. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEverySecond:
|
||||
; rcall TWI_Master_ScanNext
|
||||
rcall CPRO_OnEverySecond
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 5 seconds. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery5s:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 10 seconds. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery10s:
|
||||
#ifdef MODULES_LCD
|
||||
rcall printSendStats
|
||||
#endif
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 30 seconds. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery30s:
|
||||
#ifdef MODULES_SI7021
|
||||
in r15, SREG
|
||||
push r15
|
||||
cli
|
||||
rcall SI7021_PeriodicMeasurement
|
||||
rcall Main_SendValueMsg
|
||||
pop r15
|
||||
out SREG, r15
|
||||
#endif
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every minute. Add your routine calls here. No arguments, no results.
|
||||
|
||||
@@ -352,64 +353,6 @@ onEvery1m_l1:
|
||||
ret
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 5 minutes. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery5m:
|
||||
|
||||
#ifdef MODULES_COM
|
||||
; will later send these only every hour or so
|
||||
ldi r16, 0xff ; send stats to everybody
|
||||
rcall CPRO_EnqueueComSendStats
|
||||
|
||||
ldi r16, 0xff ; send recv to everybody
|
||||
rcall CPRO_EnqueueComRecvStats
|
||||
#endif
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 15 minutes. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery15m:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 30 minutes. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery30m:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every hour. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery1h:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every 12 hours. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery12h:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Called every day. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery1d:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; onPacketReceived:
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user