COM: Enabled packet-in counter.

This commit is contained in:
Martin Preuss
2023-01-29 18:51:15 +01:00
parent 857e358836
commit 8a395cf9c3

View File

@@ -43,6 +43,10 @@
.equ COM_CMD_I2CBUSMEMBER = 4 .equ COM_CMD_I2CBUSMEMBER = 4
.equ COM_CMD_DEBUG = 5 .equ COM_CMD_DEBUG = 5
.equ COM_ERR_NOTFORME = 1
.equ COM_ERR_CHECKSUM = 2
.equ COM_ERR_IO = 3
; *************************************************************************** ; ***************************************************************************
; data ; data
@@ -89,6 +93,8 @@ comIsrPcint0:
push r1 push r1
push r16 push r16
push r17 push r17
push r18
push r19
push r20 push r20
push r21 push r21
push r22 push r22
@@ -96,7 +102,7 @@ comIsrPcint0:
push xl push xl
push yh push yh
push yl push yl
rcall comReceivePacketHandleBuffer ; (R1, R16, R17, R20, R21, R22, X, Y) rcall comReceivePacketHandleBuffer ; (R1, R16, R17, R18, R19, R20, R21, R22, X, Y
pop yl pop yl
pop yh pop yh
pop xl pop xl
@@ -104,6 +110,8 @@ comIsrPcint0:
pop r22 pop r22
pop r21 pop r21
pop r20 pop r20
pop r19
pop r18
pop r17 pop r17
pop r16 pop r16
pop r1 pop r1
@@ -130,7 +138,7 @@ Com_Init:
ldi r17, (comDataEnd-comDataBegin) ldi r17, (comDataEnd-comDataBegin)
rcall Utils_FillSram rcall Utils_FillSram
ldi r16, 2 ; debug: set fixed address "2" ldi r16, 1 ; debug: set fixed address "1"
sts comAddress, r16 sts comAddress, r16
; setup pins and interrupts ; setup pins and interrupts
@@ -732,7 +740,7 @@ comSendPacketFromSram_error:
; - nothing ; - nothing
; OUT: ; OUT:
; - CFLAG: set if okay, cleared otherwise ; - CFLAG: set if okay, cleared otherwise
; MODIFIED REGISTERS: R16, R17, X, Y (R1, R20, R21, R22) ; MODIFIED REGISTERS: R16, R17, X, Y (R1, R18, R19, R20, R21, R22)
comReceivePacketHandleBuffer: comReceivePacketHandleBuffer:
rcall COM_BufferAlloc rcall COM_BufferAlloc
@@ -749,15 +757,27 @@ comReceivePacketHandleBuffer:
; handle buffer flags ; handle buffer flags
ldi r16, COM_BUFFER_FLAGS_RECEIVED ldi r16, COM_BUFFER_FLAGS_RECEIVED
std y+COM_BUFFER_OFFS_FLAGS, r16 std y+COM_BUFFER_OFFS_FLAGS, r16
ldi xl, LOW(comStatsPacketsIn)
ldi xh, HIGH(comStatsPacketsIn)
rcall Utils_IncrementCounter16 ; (r18, r19, 22)
sec sec
ret ret
comReceivePacketHandleBuffer_dealloc: comReceivePacketHandleBuffer_dealloc:
push r16
rcall COM_BufferDeallocBack ; (r16, r17, r21) rcall COM_BufferDeallocBack ; (r16, r17, r21)
pop r16
cpi r16, COM_ERR_NOTFORME ; packet just not for me?
breq comReceivePacketHandleBuffer_notforme ; correct, don't count as error
ldi xl, LOW(comStatsRecvErrs)
ldi xh, HIGH(comStatsRecvErrs)
rcall Utils_IncrementCounter16 ; (r18, r19, 22)
comReceivePacketHandleBuffer_error: comReceivePacketHandleBuffer_error:
clc clc
ret ret
comReceivePacketHandleBuffer_notforme: ; TODO: may count packets not for me?
clc
ret
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
@@ -782,6 +802,7 @@ comReceivePacketToSram:
lds r17, comAddress lds r17, comAddress
cp r16, r17 cp r16, r17
breq comReceivePacketToSram_acceptAddr breq comReceivePacketToSram_acceptAddr
ldi r16, COM_ERR_NOTFORME
clc ; not for me clc ; not for me
ret ret
comReceivePacketToSram_acceptAddr: comReceivePacketToSram_acceptAddr:
@@ -813,8 +834,13 @@ comReceivePacketToSram_readXOR:
brne comReceivePacketToSram_error brne comReceivePacketToSram_error
sec sec
ret ret
comReceivePacketToSram_crcError:
ldi r16, COM_ERR_CHECKSUM
clc
ret
comReceivePacketToSram_error: comReceivePacketToSram_error:
ldi r16, COM_ERR_IO
clc clc
ret ret