avr: finalized label names.

This commit is contained in:
Martin Preuss
2024-09-13 01:08:07 +02:00
parent 4ba0e01c9f
commit ee94d8a583
5 changed files with 104 additions and 44 deletions

View File

@@ -70,12 +70,12 @@
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; defines for values ; defines for values
.equ VALUE_ID_TEMP1 = 0x01 .equ VALUE_ID_SI7021_TEMP = 0x01
.equ VALUE_ID_HUM1 = 0x02 .equ VALUE_ID_SI7021_HUM = 0x02
.equ VALUE_ID_ADC = 0x03 .equ VALUE_ID_ADC = 0x03
.equ VALUE_ID_REED1 = 0x04 .equ VALUE_ID_REED1 = 0x04
.equ VALUE_ID_REED2 = 0x05 .equ VALUE_ID_REED2 = 0x05

View File

@@ -70,12 +70,12 @@
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; defines for values ; defines for values
.equ VALUE_ID_TEMP1 = 0x01 .equ VALUE_ID_SI7021_TEMP = 0x01
.equ VALUE_ID_HUM1 = 0x02 .equ VALUE_ID_SI7021_HUM = 0x02
.equ VALUE_ID_ADC = 0x03 .equ VALUE_ID_ADC = 0x03
.equ VALUE_ID_REED1 = 0x04 .equ VALUE_ID_REED1 = 0x04
.equ VALUE_ID_REED2 = 0x05 .equ VALUE_ID_REED2 = 0x05

View File

@@ -71,14 +71,16 @@
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; defines for values ; defines for values
.equ VALUE_ID_TEMP1 = 0x01 .equ VALUE_ID_SI7021_TEMP = 0x01
.equ VALUE_ID_HUM1 = 0x02 .equ VALUE_ID_SI7021_HUM = 0x02
.equ VALUE_ID_ADC = 0x03 .equ VALUE_ID_ADC = 0x03
.equ VALUE_ID_REED1 = 0x04 .equ VALUE_ID_REED1 = 0x04
.equ VALUE_ID_REED2 = 0x05 .equ VALUE_ID_REED2 = 0x05
.equ VALUE_ID_DS18B20_TEMP = 0x06 .equ VALUE_ID_DS18B20_TEMP = 0x06
.equ VALUE_ID_REED_CONF = 0x81
; *************************************************************************** ; ***************************************************************************
@@ -216,10 +218,11 @@ sramTimerEnqueueValues: .byte 2
.cseg .cseg
#ifdef MODULES_LED
ledA3Flash: .db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA3) ledA3Flash: .db DDRA+0x20, PORTA+0x20, PINA+0x20, (1<<PORTA3)
blinkPattern: .db 2, 50, 0xff, 0xff ; 1 short blink, 5s pause, restart blinkPattern: .db 2, 50, 0xff, 0xff ; 1 short blink, 5s pause, restart
;blinkPattern2: .db 2, 2, 0xff, 0xff ; 1 short blink, short pause, restart ;blinkPattern2: .db 2, 2, 0xff, 0xff ; 1 short blink, short pause, restart
#endif
@@ -274,10 +277,7 @@ periodicalLcdMark:
writeStats: writeStats:
#ifdef MODULES_DS18B20 rcall printSendStats
rcall printDs
#endif
; rcall printSendStats
ret ret
#endif #endif
@@ -304,7 +304,6 @@ sendSI7021Temp:
rjmp Timer_SetValueTo1s rjmp Timer_SetValueTo1s
sendSI7021Temp_okay: sendSI7021Temp_okay:
ret ret
#endif #endif
@@ -347,20 +346,63 @@ onEvery100ms:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; onPacketReceived: ; @routine onPacketReceived:
; ;
; Called after a packet was received via COM module. Add your routine calls here. ; Called after a packet was received via COM module. Add your routine calls here.
; ;
; The packet will be released in any case after return from this call. ; The packet will be released in any case after return from this call.
; IN: ;
; - X : pointer to received buffer ; @return CFLAG set if message handled, cleared otherwise
; OUT: ; @param X pointer to received buffer
; - CFLAG: set if handled, cleared otherwise ; @clobbers all
; USED: depending on called routines
onPacketReceived: onPacketReceived:
rcall CPRO_OnPacketReceived ; get msg code
adiw xh:xl, COM2_MSG_OFFS_CMD
ld r16, x
sbiw xh:xl, COM2_MSG_OFFS_CMD
cpi r16, CPRO_CMD_VALUE_SET
brne onPacketReceived_l1
; msg code is CPRO_CMD_VALUE_SET
rjmp onSetValueReceived
onPacketReceived_l1:
rjmp CPRO_OnPacketReceived
; @end
onSetValueReceived:
adiw xh:xl, CPRO_PACKET_VALUE_OFFS_VALUEID
ld r16, X
sbiw xh:xl, CPRO_PACKET_VALUE_OFFS_VALUEID
cpi r16, VALUE_ID_REED_CONF
brne onSetValueReceived_l1
#ifdef MODULES_REED
rjmp onSetReedConf
#else
ret
#endif
onSetValueReceived_l1:
clc
ret ret
#ifdef MODULES_REED
onSetReedConf:
; get new value
adiw xh:xl, CPRO_PACKET_VALUE_OFFS_VALUE
ld r16, X
sbiw xh:xl, CPRO_PACKET_VALUE_OFFS_VALUE
; set config
rcall REED_SetConfig
; send ACK
ldi r16, CPRO_CMD_VALUE_SET_ACK
rcall CPRO_SendSetValueResponse
sec
ret
#endif

View File

@@ -58,14 +58,14 @@
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; defines for modules ; defines for modules
.equ VALUE_ID_TEMP1 = 0x01 .equ VALUE_ID_SI7021_TEMP = 0x01
.equ VALUE_ID_HUM1 = 0x02 .equ VALUE_ID_SI7021_HUM = 0x02
.equ VALUE_ID_ADC = 0x03 .equ VALUE_ID_ADC = 0x03
.equ VALUE_ID_REED1 = 0x04 .equ VALUE_ID_REED1 = 0x04
.equ VALUE_ID_REED2 = 0x05 .equ VALUE_ID_REED2 = 0x05
.equ VALUE_ID_REED_CONF = 0x81 .equ VALUE_ID_REED_CONF = 0x81
@@ -195,6 +195,7 @@ sramTimerEnqueueValues: .byte 2
#endif #endif
#ifdef MODULES_DS18B20 #ifdef MODULES_DS18B20
sramDs18b20Timer: .byte 2 sramDs18b20Timer: .byte 2
sramSendDs18b20TempTimer: .byte 2
#endif #endif
@@ -229,14 +230,15 @@ timerList:
#endif #endif
#ifdef MODULES_SI7021 #ifdef MODULES_SI7021
.dw sramTimerSI7021Measure, SI7021_OnTimer, 0, 300 ; every 30s .dw sramTimerSI7021Measure, SI7021_OnTimer, 0, 300 ; every 30s
.dw sramTimerSI7021SendTemp, sendTemp, TIMER_FLAGS_IF_ADDR, 600 ; every 60s .dw sramTimerSI7021SendTemp, sendSI7021Temp, TIMER_FLAGS_IF_ADDR, 600 ; every 60s
.dw sramTimerSI7021SendHumidity, sendHumidity, TIMER_FLAGS_IF_ADDR, 600 ; every 60s .dw sramTimerSI7021SendHumidity, sendSI7021Humidity, TIMER_FLAGS_IF_ADDR, 600 ; every 60s
#endif #endif
#ifdef MODULES_CNY70 #ifdef MODULES_CNY70
.dw sramTimerCny70SendAdc, CNY70_OnTimer, TIMER_FLAGS_IF_ADDR, 50 ; every 5s .dw sramTimerCny70SendAdc, CNY70_OnTimer, TIMER_FLAGS_IF_ADDR, 50 ; every 5s
#endif #endif
#ifdef MODULES_DS18B20 #ifdef MODULES_DS18B20
.dw sramDs18b20Timer, Ds18b20_OnTimer, 0, 300 ; every 30s .dw sramDs18b20Timer, Ds18b20_OnTimer, 0, 300 ; every 30s
.dw sramSendDs18b20TempTimer, sendDs18b20Temp, TIMER_FLAGS_IF_ADDR, 600 ; every 60s
#endif #endif
.dw 0 ; end of list .dw 0 ; end of list
@@ -266,30 +268,41 @@ writeStats:
#endif #endif
#ifdef MODULES_SI7021 #ifdef MODULES_SI7021
sendHumidity: sendSI7021Humidity:
rcall SI7021_SendHumidity rcall SI7021_SendHumidity
brcs sendHumidity_okay brcs sendSI7021Humidity_okay
; set timer to 1s to retry later ; set timer to 1s to retry later
ldi xl, LOW(sramTimerSI7021SendHumidity) ldi xl, LOW(sramTimerSI7021SendHumidity)
ldi xh, HIGH(sramTimerSI7021SendHumidity) ldi xh, HIGH(sramTimerSI7021SendHumidity)
rjmp Timer_SetValueTo1s rjmp Timer_SetValueTo1s
sendHumidity_okay: sendSI7021Humidity_okay:
ret ret
sendTemp: sendSI7021Temp:
rcall SI7021_SendTemp rcall SI7021_SendTemp
brcs sendTemp_okay brcs sendSI7021Temp_okay
; set timer to 1s to retry later ; set timer to 1s to retry later
ldi xl, LOW(sramTimerSI7021SendTemp) ldi xl, LOW(sramTimerSI7021SendTemp)
ldi xh, HIGH(sramTimerSI7021SendTemp) ldi xh, HIGH(sramTimerSI7021SendTemp)
rjmp Timer_SetValueTo1s rjmp Timer_SetValueTo1s
sendTemp_okay: sendSI7021Temp_okay:
ret ret
#endif
#ifdef MODULES_DS18B20
sendDs18b20Temp:
rcall Ds18b20_SendTemp
brcs sendDs18b20Temp_okay
; set timer to 1s to retry later
ldi xl, LOW(sramSendDs18b20TempTimer)
ldi xh, HIGH(sramSendDs18b20TempTimer)
rjmp Timer_SetValueTo1s
sendDs18b20Temp_okay:
ret
#endif #endif
@@ -340,7 +353,7 @@ onPacketReceived:
cpi r16, CPRO_CMD_VALUE_SET cpi r16, CPRO_CMD_VALUE_SET
brne onPacketReceived_l1 brne onPacketReceived_l1
; msg code is CPRO_CMD_VALUE_SET ; msg code is CPRO_CMD_VALUE_SET
; TODO rjmp onSetValueReceived
onPacketReceived_l1: onPacketReceived_l1:
rjmp CPRO_OnPacketReceived rjmp CPRO_OnPacketReceived
@@ -348,19 +361,23 @@ onPacketReceived_l1:
onSetValueReceived: onSetValueReceived:
adiw xh:xl, CPRO_PACKET_VALUE_OFFS_VALUEID adiw xh:xl, CPRO_PACKET_VALUE_OFFS_VALUEID
ld r16, X ld r16, X
sbiw xh:xl, CPRO_PACKET_VALUE_OFFS_VALUEID sbiw xh:xl, CPRO_PACKET_VALUE_OFFS_VALUEID
cpi r16, VALUE_ID_REED_CONF cpi r16, VALUE_ID_REED_CONF
brne onSetValueReceived_l1 brne onSetValueReceived_l1
#ifdef MODULES_REED
rjmp onSetReedConf rjmp onSetReedConf
#else
ret
#endif
onSetValueReceived_l1: onSetValueReceived_l1:
clc clc
ret ret
#ifdef MODULES_REED
onSetReedConf: onSetReedConf:
; get new value ; get new value
adiw xh:xl, CPRO_PACKET_VALUE_OFFS_VALUE adiw xh:xl, CPRO_PACKET_VALUE_OFFS_VALUE
@@ -373,5 +390,6 @@ onSetReedConf:
rcall CPRO_SendSetValueResponse rcall CPRO_SendSetValueResponse
sec sec
ret ret
#endif

View File

@@ -451,7 +451,7 @@ SI7021_SendTemp:
ret ret
SI7021_SendTemp_haveValue: SI7021_SendTemp_haveValue:
ldi r16, 0xff ; destination address ldi r16, 0xff ; destination address
ldi r17, VALUE_ID_TEMP1 ; value id ldi r17, VALUE_ID_SI7021_TEMP ; value id
ldi r22, AQHOME_VALUETYPE_TEMP ldi r22, AQHOME_VALUETYPE_TEMP
lds r18, si7021LastTemp ; value lds r18, si7021LastTemp ; value
lds r19, si7021LastTemp+1 lds r19, si7021LastTemp+1
@@ -469,7 +469,7 @@ SI7021_SendHumidity:
ret ret
SI7021_SendHumidity_haveValue: SI7021_SendHumidity_haveValue:
ldi r16, 0xff ; destination address ldi r16, 0xff ; destination address
ldi r17, VALUE_ID_HUM1 ; value id ldi r17, VALUE_ID_SI7021_HUM ; value id
ldi r22, AQHOME_VALUETYPE_HUMIDITY ldi r22, AQHOME_VALUETYPE_HUMIDITY
lds r18, si7021LastHumidity ; value lds r18, si7021LastHumidity ; value
lds r19, si7021LastHumidity+1 lds r19, si7021LastHumidity+1