avr: decreased verbosity. minor fixes.

- address claiming modes now work
This commit is contained in:
Martin Preuss
2023-04-12 23:32:08 +02:00
parent ded08b8c47
commit 86b45a58e5
8 changed files with 70 additions and 131 deletions

View File

@@ -63,7 +63,7 @@ cproPacketTypeTransTableEnd:
; position within table must be in same order as in table above!
cproPacketTypeHandleTable:
.dw cproHandlePing, cproHandleNeedAddr, cproHandlePckHaveAddr, cproHandleAddrRange, cproHandleDenyAddr, cproHandleClaimAddr
.dw cproHandlePing, cproHandleNeedAddr, cproHandleHaveAddr, cproHandleAddrRange, cproHandleDenyAddr, cproHandleClaimAddr
@@ -87,21 +87,22 @@ cproHandleNeedAddr_done:
cproHandlePckHaveAddr:
cproHandleHaveAddr:
lds r17, cproMode
cpi r17, CPRO_MODE_GETADDRSTARTED
brne cproHandlePckHaveAddr_done
brne cproHandleHaveAddr_done
; validate address
adiw xh:xl, CPRO_PACKET_HAVEADDR_OFFS_ADDRESS
ld r16, x
sbiw xh:xl, CPRO_PACKET_HAVEADDR_OFFS_ADDRESS
tst r16
breq cproHandlePckHaveAddr_done ; invalid address, ignore
breq cproHandleHaveAddr_done ; invalid address, ignore
cpi r16, 127
brcc cproHandlePckHaveAddr_done ; invalid address, ignore
brcc cproHandleHaveAddr_done ; invalid address, ignore
; set bit corresponding to given address in bitfield of used addresses
dec r16
rcall cproSetBitInBitfield
cproHandlePckHaveAddr_done:
cproHandleHaveAddr_done:
sec
ret
@@ -136,9 +137,9 @@ cproHandleDenyAddr:
cpi r17, CPRO_MODE_CLAIMING_ADDR3+1
brcc cproHandleDenyAddr_notInClaimAddr13Mode
; we are in one of the three CLAIM_ADDRESS modes and received a DENY_ADDR, check address
adiw xh:xl, CPRO_PACKET_CLAIMADDR_OFFS_ADDRESS
adiw xh:xl, CPRO_PACKET_DENYADDR_OFFS_ADDRESS
ld r16, x
sbiw xh:xl, CPRO_PACKET_CLAIMADDR_OFFS_ADDRESS
sbiw xh:xl, CPRO_PACKET_DENYADDR_OFFS_ADDRESS
lds r17, cproAddrRangeBegin
cp r16, r17
brne cproHandleDenyAddr_done ; not our currently claimed address, ignore