avr: optimize for space.

This commit is contained in:
Martin Preuss
2024-09-05 03:20:00 +02:00
parent 277a27516c
commit 575b0285fe
2 changed files with 16 additions and 12 deletions

View File

@@ -83,11 +83,13 @@ bootLoader:
cbi LED_PORT, LED_PINNUM ; on
rcall flashReadUid
sts flashUid, r18
sts flashUid+1, r19
sts flashUid+2, r20
sts flashUid+3, r21
ldi xh, HIGH(flashUid)
ldi xl, LOW(flashUid)
st X+, r18
st X+, r19
st X+, r20
st X+, r21
; wait for 3 secs before doing anything else
ldi r16, 30
rcall flashWaitForMulti100ms
@@ -130,13 +132,13 @@ bootLoader_waitAndRestartBootLoader:
; OUT:
; - CFLAG: set if incoming flash request received, cleared otherwise
; - R16: message type received (if CFLAG set)
; REGS: R16, R17, X (R1, R2, R18, R19, R20, R21, R22, R24, R25)
; REGS: R16, R17, X, Y, (R1, R2, R18, R19, R20, R21, R22, R24, R25)
bootCheckFlash:
; send flash ready message
ldi xl, LOW(flashSendBuffer)
ldi xh, HIGH(flashSendBuffer)
rcall flashWriteFlashReady ; (R16, R17, R18, R19, R20, Z)
rcall flashWriteFlashReady ; (R16, R17, R18, R19, R20, Y, Z)
rcall flashSendPacketUntilSuccess ; (R16, R17, R18, R21, R22, R24, R25, X)
bootCheckFlash_loop:

View File

@@ -25,13 +25,15 @@
; - X : buffer containing the message
; OUT:
; - CFLAG: set if message is for us, cleared otherwise
; REGS: r16, r18. r19. r20, r21, X (R15, R17, R22)
; REGS: r16, r18, r19, r20, r21, X, Y (R15, R17, R22)
flashHandleFlashStart:
lds r18, flashUid
lds r19, flashUid+1
lds r20, flashUid+2
lds r21, flashUid+3
ldi yh, HIGH(flashUid)
ldi yl, LOW(flashUid)
ld r18, Y+
ld r19, Y+
ld r20, Y+
ld r21, Y
adiw xh:xl, FLASH_PACKET_START_OFFS_UID
ld r16, X+
cp r16, r18