avr: generate new uid if the current one consists of 4 equal bytes.
This commit is contained in:
@@ -397,35 +397,27 @@ Utils_SetupUid:
|
|||||||
in r15, SREG
|
in r15, SREG
|
||||||
cli
|
cli
|
||||||
rcall Utils_ReadUid ; (R16, X)
|
rcall Utils_ReadUid ; (R16, X)
|
||||||
mov r16, r18 ; all 0x00?
|
cp r18, r19 ; all the same?
|
||||||
or r16, r19
|
brne Utils_SetupUid_uidOkay ; different, jmp
|
||||||
or r16, r20
|
cp r18, r20
|
||||||
or r16, r21
|
brne Utils_SetupUid_uidOkay ; different, jmp
|
||||||
breq Utils_SetupUid_generate ; yep, go generate one
|
cp r18, r21
|
||||||
mov r16, r18 ; all 0xff?
|
brne Utils_SetupUid_uidOkay ; different, jmp
|
||||||
and r16, r19
|
ldi xl, LOW(EEPROM_OFFS_UUID) ; all the same, generate new uid
|
||||||
and r16, r20
|
|
||||||
and r16, r21
|
|
||||||
inc r16
|
|
||||||
breq Utils_SetupUid_generate ; yep, go generate one
|
|
||||||
out SREG, r15
|
|
||||||
clc
|
|
||||||
ret
|
|
||||||
Utils_SetupUid_generate:
|
|
||||||
ldi xl, LOW(EEPROM_OFFS_UUID)
|
|
||||||
ldi xh, HIGH(EEPROM_OFFS_UUID)
|
ldi xh, HIGH(EEPROM_OFFS_UUID)
|
||||||
rcall Utils_PseudoRandom ; byte 0 (R16, R17, R18, R19)
|
rcall Utils_PseudoRandom ; byte 0 (R16, R17, R18, R19)
|
||||||
inc r16
|
inc r16
|
||||||
rcall Utils_WriteEepromIncr ; (R17)
|
rcall Utils_WriteEepromIncr ; (R17)
|
||||||
rcall Utils_PseudoRandom ; byte 1
|
rcall Utils_PseudoRandom ; byte 1
|
||||||
rcall Utils_WriteEepromIncr
|
rcall Utils_WriteEepromIncr ; (R17)
|
||||||
rcall Utils_PseudoRandom ; byte 2
|
rcall Utils_PseudoRandom ; byte 2
|
||||||
rcall Utils_WriteEepromIncr
|
rcall Utils_WriteEepromIncr ; (R17)
|
||||||
rcall Utils_PseudoRandom ; byte 3
|
rcall Utils_PseudoRandom ; byte 3
|
||||||
rcall Utils_WriteEepromIncr
|
rcall Utils_WriteEepromIncr ; (R17)
|
||||||
|
|
||||||
rcall Utils_UpdateSeedInEeprom ; (R16, R17, R18, R19, X)
|
rcall Utils_UpdateSeedInEeprom ; (R16, R17, R18, R19, X)
|
||||||
|
|
||||||
|
Utils_SetupUid_uidOkay:
|
||||||
out SREG, r15
|
out SREG, r15
|
||||||
sec
|
sec
|
||||||
ret
|
ret
|
||||||
|
|||||||
Reference in New Issue
Block a user