62 lines
1.5 KiB
NASM
62 lines
1.5 KiB
NASM
; ***************************************************************************
|
|
; copyright : (C) 2023 by Martin Preuss
|
|
; email : martin@libchipcard.de
|
|
;
|
|
; ***************************************************************************
|
|
; * This file is part of the project "AqHome". *
|
|
; * Please see toplevel file COPYING of that project for license details. *
|
|
; ***************************************************************************
|
|
|
|
|
|
|
|
; ***************************************************************************
|
|
; code
|
|
|
|
|
|
.cseg
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; Write a FLASH_READY packet.
|
|
;
|
|
; IN:
|
|
; - X : buffer to write to
|
|
; OUT:
|
|
; - nothing
|
|
; MODIFIED REGS: R16, R18, Y, Z (R17, R19, R20)
|
|
|
|
flashWriteFlashReady:
|
|
ldi r16, 0xff
|
|
st X+, r16 ; dest address (unused)
|
|
ldi r16, 16 ; msg code+src address+14 payload bytes
|
|
st X+, r16 ; msg len
|
|
ldi r16, CPRO_CMD_FLASH_READY
|
|
st X+, r16 ; msg code
|
|
ldi r16, COM2_MAINTENANCE_ADDR
|
|
st X+, r16 ; src address
|
|
|
|
; payload
|
|
ldi yh, HIGH(flashUid) ; 4 bytes
|
|
ldi yl, LOW(flashUid)
|
|
ldi r18, 4
|
|
rcall Utils_Copy_SDRAM
|
|
|
|
ldi zl, low(devInfoBlock*2) ; 8 bytes
|
|
ldi zh, HIGH(devInfoBlock*2)
|
|
ldi r18, 8
|
|
rcall Utils_CopyFromFlash
|
|
|
|
ldi r16, LOW(PAGESIZE*2) ; 2 bytes
|
|
st X+, r16
|
|
ldi r16, HIGH(PAGESIZE*2)
|
|
st X+, r16
|
|
|
|
sbiw xh:xl, 18 ; go back to beginning of message
|
|
rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X)
|
|
sbiw xh:xl, 19 ; go back to beginning of message
|
|
ret
|
|
|
|
|
|
|