Files
aqhomecontrol/avr/modules/network/msg/value-r.asm
2025-04-21 00:43:11 +02:00

47 lines
1.4 KiB
NASM

; ***************************************************************************
; copyright : (C) 2025 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. *
; ***************************************************************************
; ***************************************************************************
; code
.cseg
; ---------------------------------------------------------------------------
; @routine NETMSG_ValueRead @global
; Read a VALUE message.
;
; @param X buffer to read from
; @return R17 value id
; @return R19:R18 value
; @return R21:R20 denom (e.g. 100, meaning value must be divided by 100)
; @return R22 source address
; @return R23 command
; @return R25:R24 message id
NETMSG_ValueRead:
adiw xh:xl, 2
ld r23, X+ ; command
ld r22, X+ ; src address
adiw xh:xl, 4 ; skip uid
ld r24, X+ ; msg id (low)
ld r25, X+ ; msg id (high)
ld r17, X+ ; value id
adiw xh:xl, 1 ; skip value type
ld r18, X+ ; value (low)
ld r19, X+ ; value (high)
ld r20, X+ ; denom (low)
ld r21, X+ ; denom (high)
sbiw xh:xl, 16 ; back to msg begin
ret
; @end