avr: more work on MultiFAN module (now works, tested with a single fan).
This commit is contained in:
@@ -86,10 +86,19 @@ AppReportSensors_OnEverySecond_store:
|
|||||||
breq AppReportSensors_OnEverySecond_sendValue2
|
breq AppReportSensors_OnEverySecond_sendValue2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_SGP40
|
#ifdef MODULES_MULTIFAN
|
||||||
cpi r16, 32
|
cpi r16, 32
|
||||||
|
breq AppReportSensors_OnEverySecond_sendValueMF1
|
||||||
|
cpi r16, 33
|
||||||
|
breq AppReportSensors_OnEverySecond_sendValueMF2
|
||||||
|
cpi r16, 34
|
||||||
|
breq AppReportSensors_OnEverySecond_sendValueMF3
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODULES_SGP40
|
||||||
|
cpi r16, 53
|
||||||
breq AppReportSensors_OnEverySecond_measureValue4
|
breq AppReportSensors_OnEverySecond_measureValue4
|
||||||
cpi r16, 42
|
cpi r16, 63
|
||||||
breq AppReportSensors_OnEverySecond_sendValue4
|
breq AppReportSensors_OnEverySecond_sendValue4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -145,6 +154,15 @@ AppReportSensors_OnEverySecond_sendValue3:
|
|||||||
rjmp Ds18b20_SendTemperature
|
rjmp Ds18b20_SendTemperature
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MODULES_MULTIFAN
|
||||||
|
AppReportSensors_OnEverySecond_sendValueMF1:
|
||||||
|
bigjmp MultiFan_ReportSpeed1
|
||||||
|
AppReportSensors_OnEverySecond_sendValueMF2:
|
||||||
|
bigjmp MultiFan_ReportSpeed2
|
||||||
|
AppReportSensors_OnEverySecond_sendValueMF3:
|
||||||
|
bigjmp MultiFan_ReportSpeed3
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MODULES_SGP40
|
#ifdef MODULES_SGP40
|
||||||
AppReportSensors_OnEverySecond_measureValue4:
|
AppReportSensors_OnEverySecond_measureValue4:
|
||||||
rjmp SGP40_MeasureRawSignal
|
rjmp SGP40_MeasureRawSignal
|
||||||
@@ -182,6 +200,7 @@ AppReportSensors_OnEverySecond_sendMotionValue:
|
|||||||
rjmp appMotionSendValue
|
rjmp appMotionSendValue
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
.equ AQHOME_VALUETYPE_LIGHT = 10
|
.equ AQHOME_VALUETYPE_LIGHT = 10
|
||||||
.equ AQHOME_VALUETYPE_ONOFF = 11
|
.equ AQHOME_VALUETYPE_ONOFF = 11
|
||||||
.equ AQHOME_VALUETYPE_ONOFFAUTO = 12
|
.equ AQHOME_VALUETYPE_ONOFFAUTO = 12
|
||||||
|
.equ AQHOME_VALUETYPE_RPM = 13
|
||||||
|
|
||||||
|
|
||||||
; Value Ids
|
; Value Ids
|
||||||
|
|||||||
@@ -328,6 +328,7 @@ MODULE_END_COM2W2:
|
|||||||
.include "modules/multifan/main.asm"
|
.include "modules/multifan/main.asm"
|
||||||
#ifdef MODULES_NETWORK
|
#ifdef MODULES_NETWORK
|
||||||
.include "modules/multifan/recv.asm"
|
.include "modules/multifan/recv.asm"
|
||||||
|
.include "modules/multifan/send.asm"
|
||||||
.include "devices/all/handlevaluemsg.asm"
|
.include "devices/all/handlevaluemsg.asm"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ MultiFan_Init:
|
|||||||
rcall multiFanSetupTimer
|
rcall multiFanSetupTimer
|
||||||
rcall multiFanSetupPins
|
rcall multiFanSetupPins
|
||||||
|
|
||||||
|
.ifdef MULTIFAN_SETUPIRQ_FN
|
||||||
|
bigcall MULTIFAN_SETUPIRQ_FN
|
||||||
|
.endif
|
||||||
|
|
||||||
sec
|
sec
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
@@ -68,7 +72,6 @@ MultiFan_Init:
|
|||||||
; @clobbers r16, r17, r18, r19, r24, Y
|
; @clobbers r16, r17, r18, r19, r24, Y
|
||||||
|
|
||||||
MultiFan_OnEverySecond:
|
MultiFan_OnEverySecond:
|
||||||
ret ; DEBUG
|
|
||||||
ldi yl, LOW(multiFanObjects)
|
ldi yl, LOW(multiFanObjects)
|
||||||
ldi yh, HIGH(multiFanObjects)
|
ldi yh, HIGH(multiFanObjects)
|
||||||
ldi r24, MULTIFAN_FANS
|
ldi r24, MULTIFAN_FANS
|
||||||
@@ -105,6 +108,7 @@ MultiFan_OnEverySecond_loop:
|
|||||||
std Y+MULTIFAN_FAN_OFFS_CURR_FREQUENCY_LO, r16
|
std Y+MULTIFAN_FAN_OFFS_CURR_FREQUENCY_LO, r16
|
||||||
std Y+MULTIFAN_FAN_OFFS_CURR_FREQUENCY_HI, r17
|
std Y+MULTIFAN_FAN_OFFS_CURR_FREQUENCY_HI, r17
|
||||||
|
|
||||||
|
adiw yh:yl, MULTIFAN_FAN_SIZE
|
||||||
dec r24
|
dec r24
|
||||||
brne MultiFan_OnEverySecond_loop
|
brne MultiFan_OnEverySecond_loop
|
||||||
|
|
||||||
@@ -122,13 +126,6 @@ MultiFan_OnEverySecond_loop:
|
|||||||
; @clobbers r24, r25, Y
|
; @clobbers r24, r25, Y
|
||||||
|
|
||||||
MultiFan_CheckPort:
|
MultiFan_CheckPort:
|
||||||
inr r16, MULTIFAN_TACHO_INPUT
|
|
||||||
lds r18, multiFanPrevPortVal
|
|
||||||
sts multiFanPrevPortVal, r16
|
|
||||||
eor r18, r16 ; r18: changes in bits=1
|
|
||||||
com r18 ; r18: changes in bits=0
|
|
||||||
or r18, r16 ; r18: 0=bit flipped to 0
|
|
||||||
|
|
||||||
ldi yl, LOW(multiFanObjects)
|
ldi yl, LOW(multiFanObjects)
|
||||||
ldi yh, HIGH(multiFanObjects)
|
ldi yh, HIGH(multiFanObjects)
|
||||||
|
|
||||||
@@ -243,7 +240,7 @@ multiFanIncCounter:
|
|||||||
ldd r25, Y+MULTIFAN_FAN_OFFS_COUNTER_HI
|
ldd r25, Y+MULTIFAN_FAN_OFFS_COUNTER_HI
|
||||||
adiw r25:r24, 1
|
adiw r25:r24, 1
|
||||||
std Y+MULTIFAN_FAN_OFFS_COUNTER_LO, r24
|
std Y+MULTIFAN_FAN_OFFS_COUNTER_LO, r24
|
||||||
std Y+MULTIFAN_FAN_OFFS_COUNTER_HI, r24
|
std Y+MULTIFAN_FAN_OFFS_COUNTER_HI, r25
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -292,8 +289,15 @@ multiFanSetupPins:
|
|||||||
; @clobbers r16, r17
|
; @clobbers r16, r17
|
||||||
|
|
||||||
multiFanSetupTimer:
|
multiFanSetupTimer:
|
||||||
|
.if clock == 1000000
|
||||||
; prescaler 1
|
; prescaler 1
|
||||||
ldi r16, (0<<PSR1)|(0<<DTPS11)|(0<<DTPS10) | (0<<CS13)|(0<<CS12)|(0<<CS11)|(1<<CS10)
|
ldi r16, (0<<PSR1)|(0<<DTPS11)|(0<<DTPS10) | (0<<CS13)|(0<<CS12)|(0<<CS11)|(1<<CS10)
|
||||||
|
.elif clock == 8000000
|
||||||
|
; prescaler 8
|
||||||
|
ldi r16, (0<<PSR1)|(0<<DTPS11)|(0<<DTPS10) | (0<<CS13)|(1<<CS12)|(0<<CS11)|(0<<CS10)
|
||||||
|
.else
|
||||||
|
.error "Unhandled clock"
|
||||||
|
.endif
|
||||||
outr TCCR1B, r16
|
outr TCCR1B, r16
|
||||||
; select fast PWM, enable PIN output (don't activate negated pin outputs)
|
; select fast PWM, enable PIN output (don't activate negated pin outputs)
|
||||||
.if MULTIFAN_FANS == 1
|
.if MULTIFAN_FANS == 1
|
||||||
@@ -351,7 +355,7 @@ multiFanPinChangeIsr:
|
|||||||
push r15
|
push r15
|
||||||
in r15, SREG
|
in r15, SREG
|
||||||
push r16
|
push r16
|
||||||
inr r16, MULTIFAN_TACHO_INPUT
|
in r16, MULTIFAN_TACHO_INPUT
|
||||||
push r18
|
push r18
|
||||||
lds r18, multiFanPrevPortVal
|
lds r18, multiFanPrevPortVal
|
||||||
sts multiFanPrevPortVal, r16
|
sts multiFanPrevPortVal, r16
|
||||||
|
|||||||
96
avr/modules/multifan/send.asm
Normal file
96
avr/modules/multifan/send.asm
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
; ***************************************************************************
|
||||||
|
; copyright : (C) 2026 by Martin Preuss
|
||||||
|
; email : martin@libchipcard.de
|
||||||
|
;
|
||||||
|
; ***************************************************************************
|
||||||
|
; * This file is part of the project "AqHome". *
|
||||||
|
; * Please see toplevel file COPYING of that project for license details. *
|
||||||
|
; ***************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine MultiFan_ReportSpeed1
|
||||||
|
;
|
||||||
|
; @param R17 value id
|
||||||
|
; @param R19:R18 speed (RPM)
|
||||||
|
; @clobbers R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, X
|
||||||
|
|
||||||
|
MultiFan_ReportSpeed1:
|
||||||
|
push yl
|
||||||
|
push yh
|
||||||
|
ldi yl, LOW(multiFanObjects)
|
||||||
|
ldi yh, HIGH(multiFanObjects)
|
||||||
|
ldi r17, VALUE_ID_FAN1_SPEED
|
||||||
|
ldd r18, Y+MULTIFAN_FAN_OFFS_CURR_FREQUENCY_LO
|
||||||
|
ldd r19, Y+MULTIFAN_FAN_OFFS_CURR_FREQUENCY_HI
|
||||||
|
rcall multiFanReportSpeed
|
||||||
|
pop yh
|
||||||
|
pop yl
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine MultiFan_ReportSpeed2
|
||||||
|
;
|
||||||
|
; @param R17 value id
|
||||||
|
; @param R19:R18 speed (RPM)
|
||||||
|
; @clobbers R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, X
|
||||||
|
|
||||||
|
MultiFan_ReportSpeed2:
|
||||||
|
push yl
|
||||||
|
push yh
|
||||||
|
ldi yl, LOW(multiFanObjects+MULTIFAN_FAN_SIZE)
|
||||||
|
ldi yh, HIGH(multiFanObjects+MULTIFAN_FAN_SIZE)
|
||||||
|
ldi r17, VALUE_ID_FAN2_SPEED
|
||||||
|
ldd r18, Y+MULTIFAN_FAN_OFFS_CURR_FREQUENCY_LO
|
||||||
|
ldd r19, Y+MULTIFAN_FAN_OFFS_CURR_FREQUENCY_HI
|
||||||
|
rcall multiFanReportSpeed
|
||||||
|
pop yh
|
||||||
|
pop yl
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine MultiFan_ReportSpeed2
|
||||||
|
;
|
||||||
|
; @param R17 value id
|
||||||
|
; @param R19:R18 speed (RPM)
|
||||||
|
; @clobbers R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, X
|
||||||
|
|
||||||
|
MultiFan_ReportSpeed3:
|
||||||
|
push yl
|
||||||
|
push yh
|
||||||
|
ldi yl, LOW(multiFanObjects+(MULTIFAN_FAN_SIZE*2))
|
||||||
|
ldi yh, HIGH(multiFanObjects+(MULTIFAN_FAN_SIZE*2))
|
||||||
|
ldi r17, VALUE_ID_FAN3_SPEED
|
||||||
|
ldd r18, Y+MULTIFAN_FAN_OFFS_CURR_FREQUENCY_LO
|
||||||
|
ldd r19, Y+MULTIFAN_FAN_OFFS_CURR_FREQUENCY_HI
|
||||||
|
rcall multiFanReportSpeed
|
||||||
|
pop yh
|
||||||
|
pop yl
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine multiFanReportSpeed
|
||||||
|
;
|
||||||
|
; @param R17 value id
|
||||||
|
; @param R19:R18 speed (RPM)
|
||||||
|
; @clobbers R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, X, Y
|
||||||
|
|
||||||
|
multiFanReportSpeed:
|
||||||
|
ldi r20, 1
|
||||||
|
clr r21
|
||||||
|
ldi r22, AQHOME_VALUETYPE_RPM
|
||||||
|
rcall Main_SendValueReport ; (R16, R17, R18, R19, R20, R21, R23, R24, R25, X)
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user