avr: use common code.
This commit is contained in:
@@ -21,32 +21,26 @@
|
|||||||
;
|
;
|
||||||
; IN:
|
; IN:
|
||||||
; - R16: destination address
|
; - R16: destination address
|
||||||
; - X : buffer to write to
|
|
||||||
; OUT:
|
; OUT:
|
||||||
; - nothing
|
; - nothing
|
||||||
; REGS: R3, R4, R16, R17, R18, X (R19, R20, R21)
|
; REGS: R3, R4, R16, R17, R18, X (R19, R20, R21)
|
||||||
|
|
||||||
CPRO_WriteDevice:
|
CPRO_WriteDevice:
|
||||||
ldi r17, COM2_PAYLOAD_FLAGS_UID | (6<<COM2_PAYLOAD_FLAGS_SHIFT_NUM)
|
ldi r17, COM2_PAYLOAD_FLAGS_UID | (8<<COM2_PAYLOAD_FLAGS_SHIFT_NUM)
|
||||||
ldi r18, CPRO_CMD_DEVICE
|
ldi r18, CPRO_CMD_DEVICE
|
||||||
push xh
|
rcall COM2_BeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
|
||||||
push xl
|
push yh
|
||||||
rcall COM2_BeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
|
push yl
|
||||||
lds r17, firmwareType
|
ldi zh, HIGH(devInfoBlock*2) ; 6-13: devInfoBlock
|
||||||
st X+, r17 ; 6: firmware type low
|
ldi zl, LOW(devInfoBlock*2)
|
||||||
lds r17, firmwareType+1
|
ldi r18, 8
|
||||||
st X+, r17 ; 7: firmware type high
|
rcall Utils_CopyFromFlash ; (R17, R18, X, Y)
|
||||||
lds r17, firmwareVersion
|
pop yl
|
||||||
st X+, r17 ; 8: version low
|
pop yh
|
||||||
lds r17, firmwareVersion+1
|
|
||||||
st X+, r17 ; 9: version high
|
sbiw xh:xl, 16 ; go back to beginning of message (1 byte dst addr, 1 byte length, 14 bytes payload)
|
||||||
lds r17, firmwareModules
|
rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X)
|
||||||
st X+, r17 ; 10: modules mask low
|
sbiw xh:xl, 17 ; go back to beginning of message (1 byte dst addr, 1 byte length, 14 bytes payload, 1 byte crc)
|
||||||
lds r17, firmwareModules+1
|
|
||||||
st X+, r17 ; 11: modules mask low
|
|
||||||
pop xl
|
|
||||||
pop xh
|
|
||||||
rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,35 +27,19 @@
|
|||||||
; REGS: R3, R4, R16, R17, R18, X (R19, R20, R21)
|
; REGS: R3, R4, R16, R17, R18, X (R19, R20, R21)
|
||||||
|
|
||||||
CPRO_WriteComRecvStats:
|
CPRO_WriteComRecvStats:
|
||||||
ldi r17, COM2_PAYLOAD_FLAGS_UID | (12<<COM2_PAYLOAD_FLAGS_SHIFT_NUM) ; seconds + 12 bytes payload
|
ldi r17, COM2_PAYLOAD_FLAGS_UID | ((com2RecvStatsEnd-com2RecvStatsBegin)<<COM2_PAYLOAD_FLAGS_SHIFT_NUM) ; uid + payload
|
||||||
ldi r18, CPRO_CMD_COMRECVSTATS
|
ldi r18, CPRO_CMD_COMRECVSTATS
|
||||||
push xh
|
push xh
|
||||||
push xl
|
push xl
|
||||||
rcall COM2_BeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
|
rcall COM2_BeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
|
||||||
lds r16, com2StatsPacketsIn ; packets in
|
push yh
|
||||||
st X+, r16
|
push yl
|
||||||
lds r16, com2StatsPacketsIn+1
|
ldi yh, HIGH(com2RecvStatsBegin)
|
||||||
st X+, r16
|
ldi yl, LOW(com2RecvStatsBegin)
|
||||||
lds r16, com2StatsContentError ; CRC errors
|
ldi r18, com2RecvStatsEnd-com2RecvStatsBegin
|
||||||
st X+, r16
|
rcall Utils_Copy_SDRAM ; (R17, R18, X, Y)
|
||||||
lds r16, com2StatsContentError+1
|
pop yl
|
||||||
st X+, r16
|
pop yh
|
||||||
lds r16, com2StatsIoError ; IO errors
|
|
||||||
st X+, r16
|
|
||||||
lds r16, com2StatsIoError+1
|
|
||||||
st X+, r16
|
|
||||||
lds r16, com2StatsNoBufferError ; no buffer
|
|
||||||
st X+, r16
|
|
||||||
lds r16, com2StatsNoBufferError+1
|
|
||||||
st X+, r16
|
|
||||||
lds r16, com2StatsHandled
|
|
||||||
st X+, r16
|
|
||||||
lds r16, com2StatsHandled+1
|
|
||||||
st X+, r16
|
|
||||||
lds r16, com2StatsMissed
|
|
||||||
st X+, r16
|
|
||||||
lds r16, com2StatsMissed+1
|
|
||||||
st X+, r16
|
|
||||||
pop xl
|
pop xl
|
||||||
pop xh
|
pop xh
|
||||||
rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
|
rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, X)
|
||||||
|
|||||||
@@ -24,43 +24,37 @@
|
|||||||
; - X : buffer to write to
|
; - X : buffer to write to
|
||||||
; OUT:
|
; OUT:
|
||||||
; - nothing
|
; - nothing
|
||||||
; MODIFIED REGS: R16, Z (R17, R18, R19, R20)
|
; MODIFIED REGS: R16, R18, Y, Z (R17, R19, R20)
|
||||||
|
|
||||||
flashWriteFlashReady:
|
flashWriteFlashReady:
|
||||||
ldi r16, 0xff
|
ldi r16, 0xff
|
||||||
st X+, r16 ; dest address (unused)
|
st X+, r16 ; dest address (unused)
|
||||||
ldi r16, 12 ; msg code+src address+ten payload bytes
|
ldi r16, 16 ; msg code+src address+14 payload bytes
|
||||||
st X+, r16 ; msg len
|
st X+, r16 ; msg len
|
||||||
ldi r16, CPRO_CMD_FLASH_READY
|
ldi r16, CPRO_CMD_FLASH_READY
|
||||||
st X+, r16 ; msg code
|
st X+, r16 ; msg code
|
||||||
ldi r16, COM2_MAINTENANCE_ADDR
|
ldi r16, COM2_MAINTENANCE_ADDR
|
||||||
st X+, r16 ; src address (not used)
|
st X+, r16 ; src address
|
||||||
|
|
||||||
; payload
|
; payload
|
||||||
lds r16, flashUid
|
ldi yh, HIGH(flashUid) ; 4 bytes
|
||||||
st X+, r16
|
ldi yl, LOW(flashUid)
|
||||||
lds r16, flashUid+1
|
ldi r18, 4
|
||||||
st X+, r16
|
rcall Utils_Copy_SDRAM
|
||||||
lds r16, flashUid+2
|
|
||||||
st X+, r16
|
ldi zl, low(devInfoBlock*2) ; 8 bytes
|
||||||
lds r16, flashUid+3
|
ldi zh, HIGH(devInfoBlock*2)
|
||||||
st X+, r16
|
ldi r18, 8
|
||||||
ldi zl, low(firmwareType*2)
|
rcall Utils_CopyFromFlash
|
||||||
ldi zh, HIGH(firmwareType*2)
|
|
||||||
lpm r16, Z+
|
ldi r16, LOW(PAGESIZE*2) ; 2 bytes
|
||||||
st X+, r16 ; firmwareType (low)
|
|
||||||
lpm r16, Z+
|
|
||||||
st X+, r16 ; firmwareType (high)
|
|
||||||
lpm r16, Z+
|
|
||||||
st X+, r16 ; firmwareVersion (low)
|
|
||||||
lpm r16, Z+
|
|
||||||
st X+, r16 ; firmwareVersion (high)
|
|
||||||
ldi r16, LOW(PAGESIZE*2)
|
|
||||||
st X+, r16
|
st X+, r16
|
||||||
ldi r16, HIGH(PAGESIZE*2)
|
ldi r16, HIGH(PAGESIZE*2)
|
||||||
st X, r16
|
st X+, r16
|
||||||
sbiw xh:xl, 13
|
|
||||||
|
sbiw xh:xl, 18 ; go back to beginning of message
|
||||||
rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X)
|
rcall com2CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X)
|
||||||
sbiw xh:xl, 14
|
sbiw xh:xl, 19 ; go back to beginning of message
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user