Implemented address assignment protocol.
This commit is contained in:
11
avr/com.asm
11
avr/com.asm
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user