more work on switching to new COM and TIMER stack.

This commit is contained in:
Martin Preuss
2023-04-13 21:16:51 +02:00
parent a61226c3d9
commit c00b90bf28
9 changed files with 168 additions and 64 deletions

View File

@@ -17,7 +17,7 @@
; ---------------------------------------------------------------------------
; Enqueue a VALUE packet.
; Write a VALUE packet.
;
; IN:
; - R16: destination address
@@ -25,12 +25,12 @@
; - R19:R18: value
; - R21:R20: denom (e.g. 100, meaning value must be divided by 100)
; - R22: value type
; - X : buffer to write to
; OUT:
; - CFLAG: set if okay, clear otherwise
; MODIFIED REGS: R6, R7, R8, R9, R10, R11, R12, R16, R17, X, Y (R3, R4, R15, R16, R17, R18, R19, R20, R21)
CPRO_EnqueueValue:
mov r6, r16
CPRO_WriteValue:
mov r7, r17
mov r8, r18
mov r9, r19
@@ -38,33 +38,20 @@ CPRO_EnqueueValue:
mov r11, r21
mov r12, r22
rcall COM_AllocBufferAndGetXY ; (r16, r17, r21)
brcc CPRO_EnqueueValue_error
ldi r17, COM2_PAYLOAD_FLAGS_UID | (6<<COM2_PAYLOAD_FLAGS_SHIFT_NUM)
ldi r18, CPRO_CMD_VALUE
push xh
push xl
mov r16, r6
ldi r17, CPRO_PAYLOAD_FLAGS_UID | (6<<CPRO_PAYLOAD_FLAGS_SHIFT_NUM)
ldi r18, CPRO_CMD_VALUE
rcall cproBeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
st X+, r7 ; 6: value id
st X+, r12 ; 7: value type
st X+, r8 ; 8: low value
st X+, r9 ; 9: high value
st X+, r10 ; 10: low denom
st X+, r11 ; 11: high denom
rcall COM2_BeginMsgWithVariablePayload ; R3, R4, R16, R17, R18, R19, R20, R21, X
st X+, r7 ; 6: value id
st X+, r12 ; 7: value type
st X+, r8 ; 8: low value
st X+, r9 ; 9: high value
st X+, r10 ; 10: low denom
st X+, r11 ; 11: high denom
pop xl
pop xh
rcall comCalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
; mark buffer as enqueued with PRIO "normal" (slightly limited number of retries)
ldi r20, COM_BUFFER_PRIO_NORMAL
rcall COM_EnqueuePacket ; (R15, R16)
brcc CPRO_EnqueueValue_error
sec
ret
CPRO_EnqueueValue_error:
clc
pop xh
rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
ret