reworked com stack.
- prepared for use of CRC8 - organized code in more files - recv stats message now contains crc errors and io errors
This commit is contained in:
@@ -429,5 +429,103 @@ cproSetBitInBitfield:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a NEEDADDRESS packet.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - CFLAG: set if okay, clear otherwise
|
||||
; MODIFIED REGS: R18 (R3, R4, R15, R16, R17, R20, R21, X, Y (R18, R19)
|
||||
|
||||
CPRO_EnqueueNeedAddress:
|
||||
ldi r18, CPRO_CMD_NEED_ADDRESS
|
||||
rjmp cproEnqueueAddressPacket
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a HAVE_ADDRESS packet.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - CFLAG: set if okay, clear otherwise
|
||||
; MODIFIED REGS: R18 (R3, R4, R15, R16, R17, R18, R19, R20, R21, X, Y)
|
||||
|
||||
CPRO_EnqueueHaveAddress:
|
||||
ldi r18, CPRO_CMD_HAVE_ADDRESS
|
||||
lds r19, comAddress
|
||||
rjmp cproEnqueueAddressPacket
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a CLAIM_ADDRESS packet.
|
||||
;
|
||||
; IN:
|
||||
; - R19: claimed address
|
||||
; OUT:
|
||||
; - CFLAG: set if okay, clear otherwise
|
||||
; MODIFIED REGS: R18 (R3, R4, R15, R16, R17, R18, R19, R20, R21, X, Y)
|
||||
|
||||
CPRO_EnqueueClaimAddress:
|
||||
ldi r18, CPRO_CMD_CLAIM_ADDRESS
|
||||
rjmp cproEnqueueAddressPacket
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; Enqueue a DENY_ADDRESS packet.
|
||||
;
|
||||
; IN:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - CFLAG: set if okay, clear otherwise
|
||||
; MODIFIED REGS: R18, R19 (R3, R4, R15, R16, R17, R20, R21, X, Y)
|
||||
|
||||
CPRO_EnqueueDenyAddress:
|
||||
ldi r18, CPRO_CMD_DENY_ADDRESS
|
||||
lds r19, comAddress
|
||||
rjmp cproEnqueueAddressPacket
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; cproEnqueueAddressPacket
|
||||
; Enqueue a NEED/HAVE/CLAIM ADDRESS packet.
|
||||
;
|
||||
; IN:
|
||||
; - R18: command (either CPRO_CMD_NEED_ADDRESS, CPRO_CMD_HAVE_ADDRESS or CPRO_CMD_CLAIM_ADDRESS)
|
||||
; - R19: address to send (claim, have)
|
||||
; OUT:
|
||||
; - CFLAG: set if okay, clear otherwise
|
||||
; MODIFIED REGS: R16, R17, R20, R21, X, Y (R3, R4, R15, R16, R17, R18, R19, R21, X)
|
||||
|
||||
cproEnqueueAddressPacket:
|
||||
mov r6, r19
|
||||
rcall COM_AllocBufferAndGetXY ; (r16, r17, r21)
|
||||
brcc cproEnqueueAddressPacket_error
|
||||
ldi r16, 0xff
|
||||
ldi r17, CPRO_PAYLOAD_FLAGS_UID | (1<<CPRO_PAYLOAD_FLAGS_SHIFT_NUM)
|
||||
push xh
|
||||
push xl
|
||||
rcall cproBeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
|
||||
st X+, r6 ; 5: value id
|
||||
pop xl
|
||||
pop xh
|
||||
rcall comCalcAndAddChecksumByte
|
||||
|
||||
; mark buffer as enqueued with PRIO "important" (higher retry count)
|
||||
ldi r20, COM_BUFFER_PRIO_IMPORTANT
|
||||
rcall COM_EnqueuePacket ; (R15, R16)
|
||||
brcc cproEnqueueAddressPacket_error
|
||||
sec
|
||||
ret
|
||||
cproEnqueueAddressPacket_error:
|
||||
clc
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user