avr: adapted n21 to latest changes.
This commit is contained in:
@@ -12,8 +12,3 @@
|
||||
.dseg
|
||||
|
||||
|
||||
programRamBegin:
|
||||
programRamSensorTimer: .byte 1 ; seconds counter
|
||||
programRamStatsTimer: .byte 1 ; minutes counter
|
||||
programRamEnd:
|
||||
|
||||
|
||||
@@ -79,6 +79,9 @@
|
||||
#define APPS_NETWORK
|
||||
#define APPS_MOTION
|
||||
#define APPS_DOOR
|
||||
#define APPS_REPORTSENSORS
|
||||
#define APPS_STATS
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
@@ -154,58 +157,6 @@ onSystemStart:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine systemSetSpeed
|
||||
;
|
||||
; Called every 100ms. Add your routine calls here. No arguments, no results.
|
||||
|
||||
systemSetSpeed:
|
||||
.if clock == 8000000
|
||||
ldi r16, (1<<CLKPCE)
|
||||
ldi r17, 0
|
||||
out CLKPR, r16
|
||||
out CLKPR, r17
|
||||
.endif
|
||||
|
||||
.if clock == 1000000
|
||||
ldi r16, (1<<CLKPCE)
|
||||
ldi r17, (1<<CLKPS1) | (1<<CLKPS0)
|
||||
out CLKPR, r16
|
||||
out CLKPR, r17
|
||||
.endif
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine systemInitHardware
|
||||
;
|
||||
|
||||
systemInitHardware:
|
||||
; set all ports as inputs and enable internal pull-up resistors
|
||||
ldi r16, 0xff
|
||||
clr r17
|
||||
.ifdef PORTA
|
||||
out DDRA, r17 ; all input
|
||||
out PORTA, r16 ; enable pull-up on all
|
||||
.endif
|
||||
|
||||
.ifdef PORTB
|
||||
out DDRB, r17 ; all input
|
||||
out PORTB, r16 ; enable pull-up on all
|
||||
.endif
|
||||
|
||||
.ifdef PORTC
|
||||
out DDRC, r17 ; all input
|
||||
out PORTC, r16 ; enable pull-up on all
|
||||
.endif
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine onMessageReceived
|
||||
;
|
||||
@@ -224,94 +175,22 @@ onMessageReceived:
|
||||
; Called every 100ms. Add your routine calls here. No arguments, no results.
|
||||
|
||||
onEvery100ms:
|
||||
; nothing to do here (all done in devices/all/main.asm)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine onEverySecond
|
||||
|
||||
onEverySecond:
|
||||
lds r16, programRamSensorTimer
|
||||
inc r16
|
||||
cpi r16, PROGRAM_SENSOR_INTERVAL_SECS
|
||||
brcs onEverySecond_store
|
||||
clr r16
|
||||
onEverySecond_store:
|
||||
sts programRamSensorTimer, r16
|
||||
cpi r16, 1
|
||||
breq onEverySecond_measureValue1
|
||||
cpi r16, 19
|
||||
breq onEverySecond_measureValue2
|
||||
cpi r16, 39
|
||||
breq onEverySecond_sendValue1
|
||||
cpi r16, 49
|
||||
breq onEverySecond_sendValue2
|
||||
ret
|
||||
onEverySecond_measureValue1:
|
||||
rjmp SI7021_MeasureTemp
|
||||
onEverySecond_measureValue2:
|
||||
rjmp SI7021_MeasureHumidity
|
||||
onEverySecond_sendValue1:
|
||||
rjmp SI7021_SendTemperature
|
||||
onEverySecond_sendValue2:
|
||||
rjmp SI7021_SendHumidity
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine onEveryMinute
|
||||
|
||||
onEveryMinute:
|
||||
rcall checkSendStats
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
onEveryHour:
|
||||
onEveryDay:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
checkSendStats:
|
||||
lds r16, programRamStatsTimer
|
||||
inc r16
|
||||
cpi r16, PROGRAM_STATS_INTERVAL_MINS
|
||||
brcs checkSendStats_store
|
||||
clr r16
|
||||
checkSendStats_store:
|
||||
sts programRamStatsTimer, r16
|
||||
ldi yl, LOW(netInterfaceData)
|
||||
ldi yh, HIGH(netInterfaceData)
|
||||
cpi r16, 1
|
||||
breq checkSendStats_sendDevice
|
||||
cpi r16, 2
|
||||
breq checkSendStats_sendTxdStats
|
||||
cpi r16, 3
|
||||
breq checkSendStats_sendRxdStats
|
||||
ret
|
||||
checkSendStats_sendTxdStats:
|
||||
rjmp AppNetwork_SendTxdStats
|
||||
checkSendStats_sendRxdStats:
|
||||
rjmp AppNetwork_SendRxdStats
|
||||
checkSendStats_sendDevice:
|
||||
rjmp AppNetwork_SendDevice
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; includes
|
||||
|
||||
.include "devices/all/hw_tn84.asm"
|
||||
.include "devices/all/includes.asm"
|
||||
.include "apps/network/stats.asm"
|
||||
.include "modules/network/msg/sendstats-w.asm"
|
||||
.include "modules/network/msg/recvstats-w.asm"
|
||||
.include "modules/network/msg/device-w.asm"
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user