COM: Enabled packet-in counter.
This commit is contained in:
66
avr/com.asm
66
avr/com.asm
@@ -43,6 +43,10 @@
|
||||
.equ COM_CMD_I2CBUSMEMBER = 4
|
||||
.equ COM_CMD_DEBUG = 5
|
||||
|
||||
.equ COM_ERR_NOTFORME = 1
|
||||
.equ COM_ERR_CHECKSUM = 2
|
||||
.equ COM_ERR_IO = 3
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data
|
||||
@@ -89,21 +93,25 @@ comIsrPcint0:
|
||||
push r1
|
||||
push r16
|
||||
push r17
|
||||
push r20
|
||||
push r21
|
||||
push r22
|
||||
push xh
|
||||
push xl
|
||||
push yh
|
||||
push yl
|
||||
rcall comReceivePacketHandleBuffer ; (R1, R16, R17, R20, R21, R22, X, Y)
|
||||
pop yl
|
||||
pop yh
|
||||
pop xl
|
||||
pop xh
|
||||
pop r22
|
||||
pop r21
|
||||
pop r20
|
||||
push r18
|
||||
push r19
|
||||
push r20
|
||||
push r21
|
||||
push r22
|
||||
push xh
|
||||
push xl
|
||||
push yh
|
||||
push yl
|
||||
rcall comReceivePacketHandleBuffer ; (R1, R16, R17, R18, R19, R20, R21, R22, X, Y
|
||||
pop yl
|
||||
pop yh
|
||||
pop xl
|
||||
pop xh
|
||||
pop r22
|
||||
pop r21
|
||||
pop r20
|
||||
pop r19
|
||||
pop r18
|
||||
pop r17
|
||||
pop r16
|
||||
pop r1
|
||||
@@ -130,7 +138,7 @@ Com_Init:
|
||||
ldi r17, (comDataEnd-comDataBegin)
|
||||
rcall Utils_FillSram
|
||||
|
||||
ldi r16, 2 ; debug: set fixed address "2"
|
||||
ldi r16, 1 ; debug: set fixed address "1"
|
||||
sts comAddress, r16
|
||||
|
||||
; setup pins and interrupts
|
||||
@@ -732,7 +740,7 @@ comSendPacketFromSram_error:
|
||||
; - nothing
|
||||
; OUT:
|
||||
; - 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:
|
||||
rcall COM_BufferAlloc
|
||||
@@ -744,20 +752,32 @@ comReceivePacketHandleBuffer:
|
||||
clr r17
|
||||
add xl, r16
|
||||
adc xh, r17
|
||||
rcall comReceivePacketToSram ; (r1, r16, r17, R20, R21, R22, X)
|
||||
rcall comReceivePacketToSram ; (r1, r16, r17, R20, R21, R22, X)
|
||||
brcc comReceivePacketHandleBuffer_dealloc
|
||||
; handle buffer flags
|
||||
ldi r16, COM_BUFFER_FLAGS_RECEIVED
|
||||
std y+COM_BUFFER_OFFS_FLAGS, r16
|
||||
ldi xl, LOW(comStatsPacketsIn)
|
||||
ldi xh, HIGH(comStatsPacketsIn)
|
||||
rcall Utils_IncrementCounter16 ; (r18, r19, 22)
|
||||
sec
|
||||
ret
|
||||
|
||||
comReceivePacketHandleBuffer_dealloc:
|
||||
rcall COM_BufferDeallocBack ; (r16, r17, r21)
|
||||
push r16
|
||||
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:
|
||||
clc
|
||||
ret
|
||||
|
||||
comReceivePacketHandleBuffer_notforme: ; TODO: may count packets not for me?
|
||||
clc
|
||||
ret
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
@@ -782,6 +802,7 @@ comReceivePacketToSram:
|
||||
lds r17, comAddress
|
||||
cp r16, r17
|
||||
breq comReceivePacketToSram_acceptAddr
|
||||
ldi r16, COM_ERR_NOTFORME
|
||||
clc ; not for me
|
||||
ret
|
||||
comReceivePacketToSram_acceptAddr:
|
||||
@@ -813,8 +834,13 @@ comReceivePacketToSram_readXOR:
|
||||
brne comReceivePacketToSram_error
|
||||
sec
|
||||
ret
|
||||
comReceivePacketToSram_crcError:
|
||||
ldi r16, COM_ERR_CHECKSUM
|
||||
clc
|
||||
ret
|
||||
|
||||
comReceivePacketToSram_error:
|
||||
ldi r16, COM_ERR_IO
|
||||
clc
|
||||
ret
|
||||
|
||||
|
||||
Reference in New Issue
Block a user