avr: started working on flash protocol.

This commit is contained in:
Martin Preuss
2023-04-05 22:55:21 +02:00
parent c1efe538b0
commit dfd0f3b092
2 changed files with 148 additions and 17 deletions

View File

@@ -1,19 +1,5 @@
; ***************************************************************************
; data
.dseg
flashDataBegin:
flashCurrentAddress: .byte 2
flashLastReceivedMsg: .byte 2
flashDataEnd:
; ***************************************************************************
; code
@@ -31,7 +17,7 @@ Flash_StartPage:
push zh
push zl
ldi r16, ((PAGESIZE*2)-1)
and r16, zl
and zl, r16
rcall Flash_ReadPageIntoPageBuffer
pop zl
pop zh
@@ -47,7 +33,7 @@ Flash_StartPage:
Flash_FinishPage:
ldi r16, ((PAGESIZE*2)-1)
and r16, zl
and zl, r16
rcall Flash_ErasePage
rcall Flash_WritePage
ret
@@ -76,7 +62,7 @@ Flash_ReadPageIntoPageBuffer_loop:
ldi r20, (1<<SPMEN) ; enable next SPM, write into temp page buffer
rcall utilsDoSpm ; (R16)
adiw ZH:ZL, 2
sbiw r25:r24, 2 ;use subi for PAGESIZEB<=256
sbiw r25:r24, 2 ; use subi for PAGESIZEB<=256
brne Flash_ReadPageIntoPageBuffer_loop
out SREG, r15
ret