avr: minor changes.
This commit is contained in:
@@ -48,7 +48,6 @@ Eeprom_ReadByte_waitLoop:
|
||||
sbi EECR, EERE ; start EEPROM read by writing EERE
|
||||
in r16, EEDR ; read data from data register
|
||||
|
||||
Eeprom_ReadByte_done:
|
||||
outr SREG, r15
|
||||
pop r15
|
||||
sec
|
||||
|
||||
@@ -55,6 +55,8 @@ Eeprom_WriteByte_waitLoop:
|
||||
; write data
|
||||
.ifdef EEPM1
|
||||
ldi r17, (0<<EEPM1) | (0<<EEPM0) ; set programming mode
|
||||
.else
|
||||
clr r17
|
||||
.endif
|
||||
out EECR, r17
|
||||
out EEARH, xh ; set EEPROM address
|
||||
|
||||
@@ -37,17 +37,17 @@ EepromTlv_AddTlv:
|
||||
add xl, r21 ; wanted size
|
||||
adc xh, r21
|
||||
sub xh, r21
|
||||
rcall Eeprom_CheckAddr ; check end address
|
||||
rcall Eeprom_CheckAddr ; check end address (R16)
|
||||
brcc EepromTlv_AddTlv_end
|
||||
sub xl, r21
|
||||
sbc xh, r21
|
||||
add xh, r21
|
||||
sbiw xh:xl, 2
|
||||
sbiw xh:xl, 2 ; go back to begin of TLV
|
||||
mov r16, r20 ; type
|
||||
rcall Eeprom_WriteByte
|
||||
rcall Eeprom_WriteByte ; (R17)
|
||||
adiw xh:xl, 1
|
||||
mov r16, r21 ; length
|
||||
rcall Eeprom_WriteByte
|
||||
rcall Eeprom_WriteByte ; (R17)
|
||||
adiw xh:xl, 1
|
||||
sec
|
||||
rjmp EepromTlv_AddTlv_end
|
||||
@@ -74,13 +74,13 @@ EepromTlv_AddTlv_end:
|
||||
EepromTlv_FindFirst:
|
||||
ldi xl, LOW(EEPROM_OFFS_TLV)
|
||||
ldi xh, HIGH(EEPROM_OFFS_TLV)
|
||||
rjmp EepromTlv_Find
|
||||
rjmp eepromTlvFind
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine EepromTlv_Find @global
|
||||
; @routine eepromTlvFind @global
|
||||
;
|
||||
; @param r16 TLV type to find
|
||||
; @param X EEPROM address to start search
|
||||
@@ -90,23 +90,23 @@ EepromTlv_FindFirst:
|
||||
; @return X points to begin of TLV data
|
||||
; @clobbers r18
|
||||
|
||||
EepromTlv_Find:
|
||||
eepromTlvFind:
|
||||
mov r18, r16
|
||||
EepromTlv_Find_loop:
|
||||
rcall EepromTlv_ReadHeader ; (none)
|
||||
brcc EepromTlv_Find_notFound
|
||||
eepromTlvFind_loop:
|
||||
rcall EepromTlv_ReadHeader ; r16=type, r17=len (none)
|
||||
brcc eepromTlvFind_notFound
|
||||
cp r16, r18 ; the one we wanted?
|
||||
breq EepromTlv_Find_found
|
||||
breq eepromTlvFind_found
|
||||
add xl, r17 ; skip TLV data
|
||||
adc xh, r17
|
||||
sub xh, r17
|
||||
rjmp EepromTlv_Find_loop
|
||||
EepromTlv_Find_notFound:
|
||||
rjmp eepromTlvFind_loop
|
||||
eepromTlvFind_notFound:
|
||||
clc
|
||||
rjmp EepromTlv_Find_end
|
||||
EepromTlv_Find_found:
|
||||
rjmp eepromTlvFind_end
|
||||
eepromTlvFind_found:
|
||||
sec
|
||||
EepromTlv_Find_end:
|
||||
eepromTlvFind_end:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
@@ -287,6 +287,20 @@ test:
|
||||
ldi xh, 2 ; value 0x02 (SI7021_HUM)
|
||||
bigcall OBJ_HandleSignal
|
||||
|
||||
|
||||
#if 0
|
||||
ldi xl, LOW(EEPROM_OFFS_TLV)
|
||||
ldi xh, HIGH(EEPROM_OFFS_TLV)
|
||||
eeloop:
|
||||
bigcall Eeprom_CheckAddr
|
||||
brcc eeloop_end
|
||||
ldi r16, 0xff
|
||||
bigcall Eeprom_WriteByte
|
||||
adiw xh:xl, 1
|
||||
rjmp eeloop
|
||||
eeloop_end:
|
||||
#endif
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
@@ -531,13 +531,9 @@ sensorWatchWriteToEeprom:
|
||||
tst r16
|
||||
clc
|
||||
breq sensorWatchWriteToEeprom_ret
|
||||
ldi xl, LOW(EEPROM_OFFS_TLV)
|
||||
ldi xh, HIGH(EEPROM_OFFS_TLV)
|
||||
bigcall EepromTlv_FindFirst ; (R18)
|
||||
brcs sensorWatchWriteToEeprom_write
|
||||
ldi r17, SENSORWATCH_EE_SIZE
|
||||
ldi xl, LOW(EEPROM_OFFS_TLV)
|
||||
ldi xh, HIGH(EEPROM_OFFS_TLV)
|
||||
bigcall EepromTlv_AddTlv ; X=pointer to EEPROM data (R16, R18, R20, R21)
|
||||
brcc sensorWatchWriteToEeprom_ret
|
||||
sensorWatchWriteToEeprom_write:
|
||||
@@ -569,8 +565,6 @@ sensorWatchReadFromEeprom:
|
||||
adiw zh:zl, SENSORWATCH_OFFS_EEPROMID
|
||||
lpm r16, Z
|
||||
sbiw zh:zl, SENSORWATCH_OFFS_EEPROMID
|
||||
ldi xl, LOW(EEPROM_OFFS_TLV)
|
||||
ldi xh, HIGH(EEPROM_OFFS_TLV)
|
||||
bigcall EepromTlv_FindFirst ; (R18)
|
||||
brcc sensorWatchReadFromEeprom_ret
|
||||
bigcall Widget_GetSdramPtr ; (none)
|
||||
|
||||
Reference in New Issue
Block a user