avr: new com2 and timer stack basically works again.

This commit is contained in:
Martin Preuss
2023-04-12 21:46:34 +02:00
parent 18d34450e7
commit b4c0ab273d
15 changed files with 461 additions and 171 deletions

View File

@@ -72,13 +72,13 @@
cproAddressDataBegin:
cproAddressFlags: .byte 1
cproAddresModeTimer: .byte 2
cproAddrRangeBegin: .byte 1
cproAddrRangeEnd: .byte 1
cproAddressWaitCounter: .byte 1 ; counter for seconds to wait for all nodes to respond
cproUsedAddresses: .byte 16 ; one bit per address known to b in use
cproAddressDataEnd:
cproAddresModeTimer: .byte 2 ; timer must not be zeroed, this is done by the timer module!!
; ***************************************************************************
@@ -109,20 +109,25 @@ CPRO_StartReclaimAddrProcedure:
ldi xl, LOW(EEPROM_OFFS_COMADDR)
ldi xh, HIGH(EEPROM_OFFS_COMADDR)
in r15, SREG
cli
rcall Utils_ReadEepromIncr ; (R16)
tst r16
breq CPRO_StartReclaimAddrProcedure_l1
cpi r16, 0xff
breq CPRO_StartReclaimAddrProcedure_l1
sts cproAddrRangeBegin, r16 ; currently claimed address
ldi r16, CPRO_MODE_SEND_RECLAIM_ADDR
sts cproMode, r16
rcall cproAddressSetTimer1s ; use singleshot timer, send after 1s
push r15
cli
rcall Utils_ReadEepromIncr ; (R16)
tst r16
breq CPRO_StartReclaimAddrProcedure_l1
cpi r16, 0xff
breq CPRO_StartReclaimAddrProcedure_l1
sts cproAddrRangeBegin, r16 ; currently claimed address
ldi r16, CPRO_MODE_SEND_RECLAIM_ADDR
sts cproMode, r16
rcall cproAddressSetTimer1s ; use singleshot timer, send after 1s
pop r15
out SREG, r15
sec
ret
CPRO_StartReclaimAddrProcedure_l1:
rcall CPRO_StartGetAddrProcedure
rcall CPRO_StartGetAddrProcedure
pop r15
out SREG, r15
ret