avr: work on eeprom TLV code.

This commit is contained in:
Martin Preuss
2026-01-21 22:46:18 +01:00
parent dbe42c5bcb
commit faa5991024
3 changed files with 44 additions and 29 deletions

View File

@@ -11,6 +11,12 @@
#define AQH_AVR_COMMON_EEPROM_TLV_H
; ***************************************************************************
; code
.cseg
; ---------------------------------------------------------------------------
; @routine EepromTlv_AddTlv @global
;
@@ -87,9 +93,9 @@ EepromTlv_FindFirst:
EepromTlv_Find:
mov r18, r16
EepromTlv_Find_loop:
rcall EepromTlv_ReadHeader
rcall EepromTlv_ReadHeader ; (none)
brcc EepromTlv_Find_notFound
cpi r16, r18 ; the one we wanted?
cp r16, r18 ; the one we wanted?
breq EepromTlv_Find_found
add xl, r17 ; skip TLV data
adc xh, r17
@@ -117,19 +123,20 @@ EepromTlv_Find_end:
; @clobbers none
EepromTlv_ReadHeader:
rcall Eeprom_ReadByteIncr ; read type
brcc EepromTlv_ReadHeader
rcall Eeprom_ReadByte ; read type
brcc EepromTlv_ReadHeader_ret
adiw xh:xl, 1
push r16
rcall Eeprom_ReadByteIncr ; read length
rcall Eeprom_ReadByte ; read length
mov r17, r16
pop r16
brcc EepromTlv_ReadHeader
brcc EepromTlv_ReadHeader_ret
adiw xh:xl, 1
sec
EepromTlv_ReadHeader:
EepromTlv_ReadHeader_ret:
ret
; @end
#endif