avr: re-introduce UID to new VALUE messages, set UID in VALUE response messages.
This commit is contained in:
@@ -27,29 +27,34 @@
|
||||
; @param R21:R20 denom (e.g. 100, meaning value must be divided by 100)
|
||||
; @param R22 value type
|
||||
; @param X buffer to write to
|
||||
; @clobbers R6, R7, R8, R9, R10, R11, R12, R16, R17, X, Y (R3, R4, R15, R16, R17, R18, R19, R20, R21)
|
||||
; @clobbers R16 (R17, R18, R19, R20, R21)
|
||||
|
||||
CPRO_WriteReportValue:
|
||||
st X+, r16 ; dest address
|
||||
ldi r16, 10 ; msg code+src address+8 payload bytes
|
||||
st X+, r16 ; msg len
|
||||
st X+, r16 ; dest address
|
||||
ldi r16, 14 ; msg code+src address+12 payload bytes
|
||||
st X+, r16 ; msg len
|
||||
ldi r16, CPRO_CMD_VALUE_REPORT
|
||||
st X+, r16 ; msg code
|
||||
st X+, r16 ; msg code
|
||||
ldi r16, com2Address
|
||||
st X+, r16 ; src address
|
||||
st X+, r16 ; src address
|
||||
clr r16
|
||||
st X+, r16 ; msg id/ref id, low
|
||||
st X+, r16 ; msg id/ref id, high
|
||||
st X+, r17 ; value id
|
||||
st X+, r22 ; value type
|
||||
st X+, r18 ; value (low)
|
||||
st X+, r19 ; value (high)
|
||||
st X+, r20 ; denom (low)
|
||||
st X+, r21 ; denom (high)
|
||||
push r17
|
||||
ldi r17, 6 ; uid (4 bytes), msg/ref id (2 bytes)
|
||||
rcall Utils_FillSram ; (R17)
|
||||
pop r17
|
||||
st X+, r17 ; value id
|
||||
st X+, r22 ; value type
|
||||
st X+, r18 ; value (low)
|
||||
st X+, r19 ; value (high)
|
||||
st X+, r20 ; denom (low)
|
||||
st X+, r21 ; denom (high)
|
||||
|
||||
sbiw xh:xl, 12 ; go back to UID (12=16 back, 4 forward)
|
||||
rcall COM2_AddUidToBuffer ; (r16, r18, r19, r20, r21)
|
||||
sbiw xh:xl, 8 ; go back to beginning of message
|
||||
|
||||
sbiw xh:xl, 12 ; go back to beginning of message
|
||||
rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
|
||||
sbiw xh:xl, 13 ; go back to beginning of message
|
||||
sbiw xh:xl, 16 ; go back to beginning of message
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -70,7 +75,7 @@ CPRO_WriteSetValueResponse:
|
||||
|
||||
; add checksum byte
|
||||
rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
|
||||
sbiw xh:xl, 13 ; go back to beginning of message
|
||||
sbiw xh:xl, 16 ; go back to beginning of message
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -86,7 +91,7 @@ CPRO_WriteSetValueResponse:
|
||||
; @param R21:R20 denom (e.g. 100, meaning value must be divided by 100, 0=don't change)
|
||||
; @param X buffer to write to
|
||||
; @param Y buffer with received setValueRequest message
|
||||
; @clobbers R16, R17, R18, R19, (Y)
|
||||
; @clobbers R16, R17, R18, R19, (R20, R21, Y)
|
||||
|
||||
CPRO_WriteGetValueResponse:
|
||||
push r18
|
||||
@@ -96,12 +101,12 @@ CPRO_WriteGetValueResponse:
|
||||
pop r18
|
||||
|
||||
; replace values
|
||||
adiw xh:xl, CPRO_PACKET_SETVALUE_OFFS_VALUE
|
||||
adiw xh:xl, CPRO_PACKET_VALUE_OFFS_VALUE
|
||||
st X+, r18 ; value (low)
|
||||
st X+, r19 ; value (high)
|
||||
st X+, r20 ; denom (low)
|
||||
st X+, r21 ; denom (high)
|
||||
sbiw xh:xl, CPRO_PACKET_SETVALUE_OFFS_VALUE+4
|
||||
sbiw xh:xl, CPRO_PACKET_VALUE_OFFS_VALUE+4
|
||||
|
||||
; add checksum byte
|
||||
rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
|
||||
@@ -124,9 +129,9 @@ CPRO_WriteGetValueResponse:
|
||||
cproInvertValueMsg:
|
||||
; copy received message into new message
|
||||
mov r19, r16
|
||||
ldi r18, 12 ; message size without checksum byte
|
||||
ldi r18, 16 ; message size without checksum byte
|
||||
rcall Utils_Copy_SDRAM ; (R17, R18, X, Y)
|
||||
sbiw xh:xl, 12 ; go back to beginning of message
|
||||
sbiw xh:xl, 16 ; go back to beginning of message
|
||||
|
||||
; exchange src and dest address
|
||||
adiw xh:xl, 3 ; src address
|
||||
@@ -140,7 +145,14 @@ cproInvertValueMsg:
|
||||
adiw xh:xl, 2 ; msg code
|
||||
st X, r19
|
||||
sbiw xh:xl, 2
|
||||
|
||||
; replace UID
|
||||
adiw xh:xl, CPRO_PACKET_VALUE_OFFS_UID
|
||||
rcall COM2_AddUidToBuffer ; (r16, r18, r19, r20, r21)
|
||||
sbiw xh:xl, CPRO_PACKET_VALUE_OFFS_UID+4 ; go back to beginning of message
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user