Implemented address assignment protocol.

This commit is contained in:
Martin Preuss
2023-02-05 23:42:59 +01:00
parent c1aee1e2c5
commit 716248c4e1
6 changed files with 655 additions and 46 deletions

View File

@@ -132,7 +132,14 @@ Com_Init:
ldi r17, (comDataEnd-comDataBegin)
rcall Utils_FillSram
ldi r16, 1 ; debug: set fixed address "1"
; read address from EEPROM
ldi xl, LOW(EEPROM_OFFS_COMADDR)
ldi xh, HIGH(EEPROM_OFFS_COMADDR)
rcall Utils_ReadEeprom ; (R16)
cpi r16, 0xff
brne Com_Init_l1
clr r16
Com_Init_l1:
sts comAddress, r16
; setup pins and interrupts
@@ -564,6 +571,8 @@ comReceivePacketToSram:
; compare destination address (accept "0" and own address)
tst r16
breq comReceivePacketToSram_acceptAddr
cpi r16, 0xff
breq comReceivePacketToSram_acceptAddr
lds r17, comAddress
cp r16, r17
breq comReceivePacketToSram_acceptAddr