From 29566376053ea9454aeb04303556c43346350955 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sun, 5 Feb 2023 15:38:32 +0100 Subject: [PATCH] Moved routine sendValueMsg to Main_SendValueMsg in main.asm. Removed debug code. --- avr/att84_temp1.asm | 87 +-------------------------------------------- avr/main.asm | 43 +++++++++++++++++++++- 2 files changed, 43 insertions(+), 87 deletions(-) diff --git a/avr/att84_temp1.asm b/avr/att84_temp1.asm index 9050c19..c33e37d 100644 --- a/avr/att84_temp1.asm +++ b/avr/att84_temp1.asm @@ -330,10 +330,8 @@ onEvery10s: onEvery30s: #ifdef MODULES_SI7021 rcall SI7021_PeriodicMeasurement - rcall sendValueMsg + rcall Main_SendValueMsg #endif - -; rcall Utils_SetupUid ; debug ret @@ -385,86 +383,3 @@ onPacketReceived: ret - - - - -#ifdef MODULES_COM -debugSendByte: - push r15 - in r15, SREG ; debug - cli - push r17 - push r22 - ldi r17, 8 - sbi DDRA, PORTA2 ; debug - - cbi PORTA, PORTA2 ; debug (on) - Utils_WaitNanoSecs 100000, 0, r22 ; start with 2t low - - sbi PORTA, PORTA2 ; debug (off) - nop - nop - cbi PORTA, PORTA2 ; debug (on) - Utils_WaitNanoSecs 100000, 0, r22 ; start with 2t low - - debugSendByte_loop: - lsr r16 - brcs debugSendByte_sendLow - cbi PORTA, PORTA2 ; debug (on) - rjmp debugSendByte_wait - debugSendByte_sendLow: - sbi PORTA, PORTA2 ; debug (off) - - debugSendByte_wait: - Utils_WaitNanoSecs 100000, 0, r22 - dec r17 - brne debugSendByte_loop - - cbi PORTA, PORTA2 ; debug (on) - Utils_WaitNanoSecs 200000, 0, r22 ; end with 2t low - sbi PORTA, PORTA2 ; debug (off) - pop r22 - pop r17 - out SREG, r15 - pop r15 - ret -#endif - - - -sendValueMsg: - ; send message for current temp - lds r22, si7021Flags - mov r16, r22 - andi r16, SI7021_FLAGS_TEMP_VALID - breq sendValueMsg_checkHum - ldi r16, 0xff ; destination address - ldi r17, VALUE_ID_TEMP1 ; value id - push r22 - ldi r22, AQHOME_VALUETYPE_TEMP - lds r18, si7021LastTemp ; value - lds r19, si7021LastTemp+1 - ldi r20, 100 ; denominator - clr r21 - rcall CPRO_EnqueueValue - pop r22 -sendValueMsg_checkHum: - mov r16, r22 - andi r16, SI7021_FLAGS_HUM_VALID - breq sendValueMsg_done - ldi r16, 0xff ; destination address - ldi r17, VALUE_ID_HUM1 ; value id - push r22 - ldi r22, AQHOME_VALUETYPE_HUMIDITY - lds r18, si7021LastHumidity ; value - lds r19, si7021LastHumidity+1 - ldi r20, 1 ; denominator - clr r21 - rcall CPRO_EnqueueValue - pop r22 -sendValueMsg_done: - ret - - - diff --git a/avr/main.asm b/avr/main.asm index 07cba7d..87d6faf 100644 --- a/avr/main.asm +++ b/avr/main.asm @@ -193,6 +193,7 @@ printSendStats: rcall LCD_PrintHexWord +#ifdef MODULES_COM ldi r18, 0 ldi r19, 4 rcall LCD_SetCursor @@ -233,11 +234,51 @@ printSendStats: lds r18, comStatsCollisions lds r19, comStatsCollisions+1 rcall LCD_PrintHexWord +#endif pop r15 out SREG, r15 ret - + + + +#ifdef MODULES_SI7021 +#ifdef MODULES_COM + +Main_SendValueMsg: + ; send message for current temp + lds r22, si7021Flags + mov r16, r22 + andi r16, SI7021_FLAGS_TEMP_VALID + breq sendValueMsg_checkHum + ldi r16, 0xff ; destination address + ldi r17, VALUE_ID_TEMP1 ; value id + push r22 + ldi r22, AQHOME_VALUETYPE_TEMP + lds r18, si7021LastTemp ; value + lds r19, si7021LastTemp+1 + ldi r20, 100 ; denominator + clr r21 + rcall CPRO_EnqueueValue + pop r22 +sendValueMsg_checkHum: + mov r16, r22 + andi r16, SI7021_FLAGS_HUM_VALID + breq sendValueMsg_done + ldi r16, 0xff ; destination address + ldi r17, VALUE_ID_HUM1 ; value id + push r22 + ldi r22, AQHOME_VALUETYPE_HUMIDITY + lds r18, si7021LastHumidity ; value + lds r19, si7021LastHumidity+1 + ldi r20, 1 ; denominator + clr r21 + rcall CPRO_EnqueueValue + pop r22 +sendValueMsg_done: + ret +#endif +#endif textSi7021Firmware: .db "SI: ", 0, 0