avr: Try to fix a bug (not respecting DENY_ADDRESS).
This commit is contained in:
@@ -41,7 +41,8 @@ cproAddressOnTimerTable:
|
|||||||
.dw cproHandle1sSendingHaveAddress ; CPRO_MODE_SENDING_HAVE_ADDR
|
.dw cproHandle1sSendingHaveAddress ; CPRO_MODE_SENDING_HAVE_ADDR
|
||||||
.dw cproHandle1sSendReclaimAddr ; CPRO_MODE_SEND_RECLAIM_ADDR
|
.dw cproHandle1sSendReclaimAddr ; CPRO_MODE_SEND_RECLAIM_ADDR
|
||||||
.dw cproHandle1sReclaimingAddr ; CPRO_MODE_RECLAIMING_ADDR
|
.dw cproHandle1sReclaimingAddr ; CPRO_MODE_RECLAIMING_ADDR
|
||||||
.dw cproHandle1sSendDenyAddr ; CPRO_MODE_SEND_DENY_ADDR
|
.dw cproHandle1sSendDenyAddr1 ; CPRO_MODE_SEND_DENY_ADDR1
|
||||||
|
.dw cproHandle1sSendDenyAddr2 ; CPRO_MODE_SEND_DENY_ADDR2
|
||||||
|
|
||||||
|
|
||||||
cproHandle1sSendingHaveAddress:
|
cproHandle1sSendingHaveAddress:
|
||||||
@@ -70,11 +71,24 @@ cproHandle1sNeedAddr_okay:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cproHandle1sSendDenyAddr:
|
cproHandle1sSendDenyAddr1:
|
||||||
rcall CPRO_SendDenyAddress
|
rcall CPRO_SendDenyAddress
|
||||||
brcs cproHandle1sSendDenyAddr_okay
|
brcs cproHandle1sSendDenyAddr1_okay
|
||||||
rjmp cproAddressSetTimer1s ; could not send, restart timer 1s and retry later
|
rjmp cproAddressSetTimer1s ; could not send, restart timer 1s and retry later
|
||||||
cproHandle1sSendDenyAddr_okay:
|
cproHandle1sSendDenyAddr1_okay:
|
||||||
|
ldi r16, CPRO_MODE_SEND_DENY_ADDR2 ; DENY_ADDR sent, send 2nd later
|
||||||
|
sts cproMode, r16
|
||||||
|
ldi r18, LOW(CPRO_WAITTIME_SENDDENY2) ; set timeout
|
||||||
|
ldi r19, HIGH(CPRO_WAITTIME_SENDDENY2) ; set timeout
|
||||||
|
rjmp cproAddressSetTimer
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
cproHandle1sSendDenyAddr2:
|
||||||
|
rcall CPRO_SendDenyAddress
|
||||||
|
brcs cproHandle1sSendDenyAddr2_okay
|
||||||
|
rjmp cproAddressSetTimer1s ; could not send, restart timer 1s and retry later
|
||||||
|
cproHandle1sSendDenyAddr2_okay:
|
||||||
ldi r16, CPRO_MODE_NORMAL ; DENY_ADDR sent, back to normal
|
ldi r16, CPRO_MODE_NORMAL ; DENY_ADDR sent, back to normal
|
||||||
sts cproMode, r16
|
sts cproMode, r16
|
||||||
ret
|
ret
|
||||||
|
|||||||
@@ -39,38 +39,42 @@ CPRO_Address_OnPacketReceived:
|
|||||||
ld r16, x
|
ld r16, x
|
||||||
sbiw xh:xl, COM2_MSG_OFFS_CMD
|
sbiw xh:xl, COM2_MSG_OFFS_CMD
|
||||||
|
|
||||||
|
cpi r16, CPRO_CMD_DENY_ADDRESS
|
||||||
|
breq CPRO_Address_OnPacketReceived_denyAddr
|
||||||
|
|
||||||
|
cpi r16, CPRO_CMD_CLAIM_ADDRESS
|
||||||
|
breq CPRO_Address_OnPacketReceived_claimAddr
|
||||||
|
|
||||||
|
rjmp CPRO_Address_OnPacketReceived_nc
|
||||||
|
|
||||||
cpi r16, CPRO_CMD_NEED_ADDRESS
|
cpi r16, CPRO_CMD_NEED_ADDRESS
|
||||||
brcs CPRO_Address_OnPacketReceived_nc ; smaller than 60
|
brcs CPRO_Address_OnPacketReceived_nc ; smaller than 60
|
||||||
|
|
||||||
cpi r16, (CPRO_CMD_ADDRESS_RANGE+1)
|
cpi r16, (CPRO_CMD_ADDRESS_RANGE+1)
|
||||||
brcc CPRO_Address_OnPacketReceived_nc
|
brcc CPRO_Address_OnPacketReceived_nc
|
||||||
|
|
||||||
CPRO_Address_OnPacketReceived_debug2:
|
subi r16, CPRO_CMD_NEED_ADDRESS
|
||||||
ldi r17, (cproPacketTypeTransTableEnd-cproPacketTypeTransTableBegin)*2
|
ldi r17, (cproPacketTypeHandleTableEnd-cproPacketTypeHandleTableBegin)
|
||||||
ldi zl, LOW(cproPacketTypeTransTableBegin)
|
ldi zl, LOW(cproPacketTypeHandleTableBegin)
|
||||||
ldi zh, HIGH(cproPacketTypeTransTableBegin)
|
ldi zh, HIGH(cproPacketTypeHandleTableBegin)
|
||||||
rcall Utils_FindBytePositionInTable
|
|
||||||
brcc CPRO_Address_OnPacketReceived_nc
|
|
||||||
|
|
||||||
ldi r17, (cproPacketTypeTransTableEnd-cproPacketTypeTransTableBegin)*2
|
|
||||||
ldi zl, LOW(cproPacketTypeHandleTable)
|
|
||||||
ldi zh, HIGH(cproPacketTypeHandleTable)
|
|
||||||
rcall Utils_TableJump
|
rcall Utils_TableJump
|
||||||
sec
|
sec
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
CPRO_Address_OnPacketReceived_denyAddr:
|
||||||
|
rjmp cproHandleDenyAddr
|
||||||
|
CPRO_Address_OnPacketReceived_claimAddr:
|
||||||
|
rjmp cproHandleClaimAddr
|
||||||
CPRO_Address_OnPacketReceived_nc:
|
CPRO_Address_OnPacketReceived_nc:
|
||||||
clc
|
clc
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cproPacketTypeTransTableBegin:
|
; fixed position from CPRO_CMD_NEED_ADDRESS to CPRO_CMD_ADDRESS_RANGE!!
|
||||||
.db CPRO_CMD_NEED_ADDRESS, CPRO_CMD_HAVE_ADDRESS, CPRO_CMD_ADDRESS_RANGE, CPRO_CMD_DENY_ADDRESS, CPRO_CMD_CLAIM_ADDRESS, CPRO_CMD_PING
|
cproPacketTypeHandleTableBegin:
|
||||||
cproPacketTypeTransTableEnd:
|
.dw cproHandleNeedAddr, cproHandleHaveAddr, cproHandleClaimAddr, cproHandleDenyAddr, cproHandleAddrRange
|
||||||
|
cproPacketTypeHandleTableEnd:
|
||||||
; position within table must be in same order as in table above!
|
|
||||||
cproPacketTypeHandleTable:
|
|
||||||
.dw cproHandleNeedAddr, cproHandleHaveAddr, cproHandleAddrRange, cproHandleDenyAddr, cproHandleClaimAddr, cproHandlePing
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -136,7 +140,7 @@ cproHandleClaimAddr:
|
|||||||
breq cproHandleClaimAddr_done ; we have no address, yet
|
breq cproHandleClaimAddr_done ; we have no address, yet
|
||||||
cp r16, r17
|
cp r16, r17
|
||||||
brne cproHandleClaimAddr_done ; not our address
|
brne cproHandleClaimAddr_done ; not our address
|
||||||
ldi r16, CPRO_MODE_SEND_DENY_ADDR
|
ldi r16, CPRO_MODE_SEND_DENY_ADDR1
|
||||||
sts cproMode, r16
|
sts cproMode, r16
|
||||||
rcall cproAddressSetTimer1s
|
rcall cproAddressSetTimer1s
|
||||||
|
|
||||||
@@ -147,6 +151,9 @@ cproHandleClaimAddr_done:
|
|||||||
|
|
||||||
|
|
||||||
cproHandleDenyAddr:
|
cproHandleDenyAddr:
|
||||||
|
; debug
|
||||||
|
; cbi LED_SIMPLE_PORT, LED_SIMPLE_PINNUM ; on
|
||||||
|
|
||||||
; check mode
|
; check mode
|
||||||
lds r17, cproMode
|
lds r17, cproMode
|
||||||
cpi r17, CPRO_MODE_CLAIMING_ADDR1
|
cpi r17, CPRO_MODE_CLAIMING_ADDR1
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
.equ CPRO_WAITTIME_GETADDR = 1300
|
.equ CPRO_WAITTIME_GETADDR = 1300
|
||||||
.equ CPRO_WAITTIME_CLAIMADDR = 170
|
.equ CPRO_WAITTIME_CLAIMADDR = 170
|
||||||
.equ CPRO_WAITTIME_RECLAIMADDR = 100
|
.equ CPRO_WAITTIME_RECLAIMADDR = 100
|
||||||
|
.equ CPRO_WAITTIME_SENDDENY2 = 50
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
@@ -93,8 +94,9 @@
|
|||||||
.equ CPRO_MODE_SENDING_HAVE_ADDR = 0x08 ; waiting for our turn to send HAVE_ADDRESS packet
|
.equ CPRO_MODE_SENDING_HAVE_ADDR = 0x08 ; waiting for our turn to send HAVE_ADDRESS packet
|
||||||
.equ CPRO_MODE_SEND_RECLAIM_ADDR = 0x09 ; send CLAIM_ADDRESS as part of reclaiming procedure
|
.equ CPRO_MODE_SEND_RECLAIM_ADDR = 0x09 ; send CLAIM_ADDRESS as part of reclaiming procedure
|
||||||
.equ CPRO_MODE_RECLAIMING_ADDR = 0x0a ; CLAIM_ADDRESS with the previously used address sent after bootup
|
.equ CPRO_MODE_RECLAIMING_ADDR = 0x0a ; CLAIM_ADDRESS with the previously used address sent after bootup
|
||||||
.equ CPRO_MODE_SEND_DENY_ADDR = 0x0b ; someone claimed our address, send a DENY_ADDR message
|
.equ CPRO_MODE_SEND_DENY_ADDR1 = 0x0b ; someone claimed our address, send a DENY_ADDR message
|
||||||
.equ CPRO_MODE_NEXT_FREE = 0x0c ; next free mode
|
.equ CPRO_MODE_SEND_DENY_ADDR2 = 0x0c ; someone claimed our address, send a DENY_ADDR message
|
||||||
|
.equ CPRO_MODE_NEXT_FREE = 0x0d ; next free mode
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user