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