avr: more work on basic device code.

This commit is contained in:
Martin Preuss
2025-05-04 03:33:32 +02:00
parent e25b0ad69d
commit 9a854977a4
6 changed files with 48 additions and 28 deletions

View File

@@ -26,21 +26,18 @@
Main_SendValueReport:
push r17
rcall NET_Buffer_Alloc ; (R16, R17, X)
rcall NET_Buffer_Alloc ; (R16, R17, X)
pop r17
brcc Main_SendValueReport_end ; jmp on error
push r16 ; buffer num
ldi r16, 0xff ; DEST addr
brcc Main_SendValueReport_end ; jmp on error
push r16 ; buffer num
ldi r16, 0xff ; DEST addr
adiw xh:xl, 1
ldi yl, LOW(netInterfaceData)
ldi yh, HIGH(netInterfaceData)
rcall NETMSG_ValueWriteReport ; (R16, R17, R18, R19, R20, R21, R23, R24, R25)
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 Main_SendValueReport_end ; jump if okay
rcall NET_Buffer_ReleaseByNum ; otherwise release buffer
clc
pop r16 ; buffer num
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
Main_SendValueReport_end:
ret
; @end
@@ -53,27 +50,24 @@ Main_SendValueReport_end:
; @param R17 value id
; @param R19:R18 value
; @param R21:R20 denom (e.g. 100, meaning value must be divided by 100)
; @param R22 value type
; @param R23 command
; @param R25:R24 ref msg id
Main_SendValueResponse:
push r17
rcall NET_Buffer_Alloc ; (R16, R17, X)
rcall NET_Buffer_Alloc ; (R16, R17, X)
pop r17
brcc Main_SendValueResponse_end ; jmp on error
push r16 ; buffer num
ldi r16, 0xff ; DEST addr
brcc Main_SendValueResponse_end ; jmp on error
push r16 ; buffer num
ldi r16, 0xff ; DEST addr
clr r22 ; value type
adiw xh:xl, 1
ldi yl, LOW(netInterfaceData)
ldi yh, HIGH(netInterfaceData)
rcall NETMSG_ValueWriteResponse ; (R16, R17, R18, R19, R20, R21, R23, R24, R25)
rcall NETMSG_ValueWriteResponse ; (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 Main_SendValueResponse_end ; jump if okay
rcall NET_Buffer_ReleaseByNum ; otherwise release buffer
clc
pop r16 ; buffer num
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
Main_SendValueResponse_end:
ret
; @end