N23 basically works now.

This commit is contained in:
Martin Preuss
2025-04-26 11:04:01 +02:00
parent feabc76e36
commit 8925ce23e9
4 changed files with 258 additions and 102 deletions

View File

@@ -70,32 +70,13 @@ AppMotion_Every100ms:
ldi yl, LOW(appMotionValSchedData)
ldi yh, HIGH(appMotionValSchedData)
rcall FilterKeepUp_SetValue ; (R17)
rcall ValueScheduler_SetValue ; (R17)
rcall ValueScheduler_Every100ms ; (R16, R17)
rcall ValueScheduler_CheckSend ; (R16)
brcc AppMotion_Every100ms_end
rcall NET_Buffer_Alloc
; prepare and send value message
rcall appMotionSendValue
brcc AppMotion_Every100ms_end ; jmp on error
push r16 ; buffer num
rcall ValueScheduler_GetValue ; get value to r16
mov r18, r16 ; R19:R18 = value
clr r19
ldi r16, 0xff ; DEST addr
ldi r17, VALUE_ID_MOTION ; VALUE ID
ldi r20, 1 ; R21:R20 = denom
clr r21
ldi r22, AQHOME_VALUETYPE_MOTION ; VALUE TYPE
adiw xh:xl, 1
rcall NETMSG_ValueWriteReport ; (R16, R17, R18, R19, R20, R21, R23, R24, R25)
sbiw xh:xl, 1
pop r16 ; buffer num
ldi yl, LOW(netInterfaceData)
ldi yh, HIGH(netInterfaceData)
rcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X)
brcs AppMotion_Every100ms_markSent
rcall NET_Buffer_ReleaseByNum
rjmp AppMotion_Every100ms_end
AppMotion_Every100ms_markSent:
ldi yl, LOW(appMotionValSchedData)
ldi yh, HIGH(appMotionValSchedData)
rcall ValueScheduler_MarkSent ; (R16)
@@ -105,4 +86,41 @@ AppMotion_Every100ms_end:
; ---------------------------------------------------------------------------
; @routine appMotionSendValue
;
; @return CFLAGS set if message enqueued, cleared on error
; @clobbers R17, R18, R19, R20, R21, R22, Y (R16, R23, R24, R25)
appMotionSendValue:
rcall NET_Buffer_Alloc ; (R16, R17, X)
brcc appMotionSendValue_end ; jmp on error
push r16 ; buffer num
ldi yl, LOW(appMotionValSchedData)
ldi yh, HIGH(appMotionValSchedData)
rcall ValueScheduler_GetValue ; get value to r16
mov r18, r16 ; R19:R18 = value
clr r19
ldi r16, 0xff ; DEST addr
ldi r17, VALUE_ID_MOTION ; VALUE ID
ldi r20, 1 ; R21:R20 = denom
clr r21
ldi r22, AQHOME_VALUETYPE_MOTION ; VALUE TYPE
adiw xh:xl, 1
ldi yl, LOW(netInterfaceData)
ldi yh, HIGH(netInterfaceData)
rcall NETMSG_ValueWriteReport ; (R16, R17, R18, R19, R20, R21, R23, R24, R25)
sbiw xh:xl, 1
pop r16 ; buffer num
rcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X)
brcs appMotionSendValue_end ; jump if okay
rcall NET_Buffer_ReleaseByNum ; otherwise release buffer
clc
appMotionSendValue_end:
ret
; @end