avr: more comments, minor reformatting.
This commit is contained in:
@@ -60,11 +60,11 @@ RAM_23LC512_Init:
|
|||||||
; @routine RAM_23LC512_StartWriting @global
|
; @routine RAM_23LC512_StartWriting @global
|
||||||
;
|
;
|
||||||
; @param X destination address
|
; @param X destination address
|
||||||
; @clobbers r16-r19, r23
|
; @clobbers r16, r17, r23
|
||||||
|
|
||||||
RAM_23LC512_StartWriting:
|
RAM_23LC512_StartWriting:
|
||||||
ldi r16, RAM_23LC512_CMD_WRITE
|
ldi r16, RAM_23LC512_CMD_WRITE
|
||||||
rjmp ram23LC512StartTransfer ; (r16-r19, r23)
|
rjmp ram23LC512StartTransfer ; (r16, r17, r23)
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
@@ -73,11 +73,11 @@ RAM_23LC512_StartWriting:
|
|||||||
; @routine RAM_23LC512_StartReading @global
|
; @routine RAM_23LC512_StartReading @global
|
||||||
;
|
;
|
||||||
; @param X source address
|
; @param X source address
|
||||||
; @clobbers r16-r19, r23
|
; @clobbers r16, r17, r23
|
||||||
|
|
||||||
RAM_23LC512_StartReading:
|
RAM_23LC512_StartReading:
|
||||||
ldi r16, RAM_23LC512_CMD_READ
|
ldi r16, RAM_23LC512_CMD_READ
|
||||||
rjmp ram23LC512StartTransfer ; (r16-r19, r23)
|
rjmp ram23LC512StartTransfer ; (r16, r17, r23)
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|
||||||
@@ -85,10 +85,11 @@ RAM_23LC512_StartReading:
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine RAM_23LC512_EndTransfer @global
|
; @routine RAM_23LC512_EndTransfer @global
|
||||||
;
|
;
|
||||||
|
; @clobbers none
|
||||||
|
|
||||||
RAM_23LC512_EndTransfer:
|
RAM_23LC512_EndTransfer:
|
||||||
sbi RAMCS_OUTPUT, RAMCS_PIN ; CS high
|
sbi RAMCS_OUTPUT, RAMCS_PIN ; CS high
|
||||||
bigcall SPISW_MasterStop
|
bigcall SPISW_MasterStop ; (none)
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -99,19 +100,22 @@ RAM_23LC512_EndTransfer:
|
|||||||
;
|
;
|
||||||
; @param X source address
|
; @param X source address
|
||||||
; @param Y destination address
|
; @param Y destination address
|
||||||
; @param R25:r24 number of bytes to read
|
; @param R17 number of bytes to read
|
||||||
; @clobbers r16-r19, r23-r25
|
; @clobbers r16, r17, r23
|
||||||
|
|
||||||
RAM_23LC512_ReadBytes:
|
RAM_23LC512_ReadBytes:
|
||||||
rcall RAM_23LC512_StartReading ; (r16-r19, r23)
|
push r22
|
||||||
|
mov r22, r17
|
||||||
|
rcall RAM_23LC512_StartReading ; (r16, r17, r23)
|
||||||
|
|
||||||
RAM_23LC512_ReadBytes_loop:
|
RAM_23LC512_ReadBytes_loop:
|
||||||
ldi r16, 0xff
|
ldi r16, 0xff
|
||||||
bigcall SPISW_MasterExchangeByteMode0 ; (r17, r18, r19, r23)
|
bigcall SPISW_MasterExchangeByteMode0 ; (r17, r23)
|
||||||
st Y+, r16
|
st Y+, r16
|
||||||
sbiw r25:r24, 1
|
dec r22
|
||||||
brne RAM_23LC512_ReadBytes_loop
|
brne RAM_23LC512_ReadBytes_loop
|
||||||
rcall RAM_23LC512_EndTransfer
|
rcall RAM_23LC512_EndTransfer
|
||||||
|
pop r22
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -122,18 +126,21 @@ RAM_23LC512_ReadBytes_loop:
|
|||||||
;
|
;
|
||||||
; @param X destination address
|
; @param X destination address
|
||||||
; @param Y source address
|
; @param Y source address
|
||||||
; @param R25:r24 number of bytes to write
|
; @param R17 number of bytes to read
|
||||||
; @clobbers r16-r19, r23-r25
|
; @clobbers r16, r17, r23
|
||||||
|
|
||||||
RAM_23LC512_WriteBytes:
|
RAM_23LC512_WriteBytes:
|
||||||
rcall RAM_23LC512_StartWriting ; (r16-r19, r23)
|
push r22
|
||||||
|
mov r22, r17
|
||||||
|
rcall RAM_23LC512_StartWriting ; (r16, r17, r23)
|
||||||
|
|
||||||
RAM_23LC512_WriteBytes_loop:
|
RAM_23LC512_WriteBytes_loop:
|
||||||
ld r16, Y+
|
ld r16, Y+
|
||||||
bigcall SPISW_MasterExchangeByteMode0 ; (r17, r18, r19, r23)
|
bigcall SPISW_MasterExchangeByteMode0 ; (r17, r23)
|
||||||
sbiw r25:r24, 1
|
dec r22
|
||||||
brne RAM_23LC512_WriteBytes_loop
|
brne RAM_23LC512_WriteBytes_loop
|
||||||
rcall RAM_23LC512_EndTransfer
|
rcall RAM_23LC512_EndTransfer ; (none)
|
||||||
|
pop r22
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -165,23 +172,25 @@ RAM_23LC512_Fill_loop:
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine RAM_23LC512_WritePattern @global
|
; @routine RAM_23LC512_WritePattern @global
|
||||||
;
|
;
|
||||||
; @clobbers r16-r19, r23-r25
|
; @clobbers r16, r17, r23, X
|
||||||
|
|
||||||
RAM_23LC512_WritePattern:
|
RAM_23LC512_WritePattern:
|
||||||
|
push r24
|
||||||
|
push r25
|
||||||
clr xl
|
clr xl
|
||||||
clr xh
|
clr xh
|
||||||
rcall RAM_23LC512_StartWriting ; (r16-r19, r23)
|
rcall RAM_23LC512_StartWriting ; (r16, r17, r23)
|
||||||
ldi r24, LOW(RAM_23LC512_PATTERNSIZE)
|
ldi r24, LOW(RAM_23LC512_PATTERNSIZE)
|
||||||
ldi r25, HIGH(RAM_23LC512_PATTERNSIZE)
|
ldi r25, HIGH(RAM_23LC512_PATTERNSIZE)
|
||||||
clr xl
|
|
||||||
clr xh
|
|
||||||
RAM_23LC512_WritePattern_loop:
|
RAM_23LC512_WritePattern_loop:
|
||||||
mov r16, xh
|
mov r16, xh
|
||||||
bigcall SPISW_MasterExchangeByteMode0 ; (r17, r18, r19, r23)
|
bigcall SPISW_MasterExchangeByteMode0 ; (r16, r17, r23)
|
||||||
adiw xh:xl, 1
|
adiw xh:xl, 1
|
||||||
sbiw r25:r24, 1
|
sbiw r25:r24, 1
|
||||||
brne RAM_23LC512_WritePattern_loop
|
brne RAM_23LC512_WritePattern_loop
|
||||||
rcall RAM_23LC512_EndTransfer
|
rcall RAM_23LC512_EndTransfer
|
||||||
|
pop r25
|
||||||
|
pop r24
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -190,19 +199,19 @@ RAM_23LC512_WritePattern_loop:
|
|||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine RAM_23LC512_ReadPattern @global
|
; @routine RAM_23LC512_ReadPattern @global
|
||||||
;
|
;
|
||||||
; @clobbers r16-r19, r23-r25
|
; @clobbers r16, r17, r23, X
|
||||||
|
|
||||||
RAM_23LC512_ReadPattern:
|
RAM_23LC512_ReadPattern:
|
||||||
|
push r24
|
||||||
|
push r25
|
||||||
clr xl
|
clr xl
|
||||||
clr xh
|
clr xh
|
||||||
rcall RAM_23LC512_StartReading ; (r16-r19, r23)
|
rcall RAM_23LC512_StartReading ; (r16, r17, r23)
|
||||||
ldi r24, LOW(RAM_23LC512_PATTERNSIZE)
|
ldi r24, LOW(RAM_23LC512_PATTERNSIZE)
|
||||||
ldi r25, HIGH(RAM_23LC512_PATTERNSIZE)
|
ldi r25, HIGH(RAM_23LC512_PATTERNSIZE)
|
||||||
clr xl
|
|
||||||
clr xh
|
|
||||||
RAM_23LC512_ReadPattern_loop:
|
RAM_23LC512_ReadPattern_loop:
|
||||||
ldi r16, 0xff
|
ldi r16, 0xff
|
||||||
bigcall SPISW_MasterExchangeByteMode0 ; (r17, r18, r19, r23)
|
bigcall SPISW_MasterExchangeByteMode0 ; r16=value read (r17, r23)
|
||||||
cp r16, xh
|
cp r16, xh
|
||||||
clc
|
clc
|
||||||
brne RAM_23LC512_ReadPattern_ret
|
brne RAM_23LC512_ReadPattern_ret
|
||||||
@@ -212,6 +221,8 @@ RAM_23LC512_ReadPattern_loop:
|
|||||||
rcall RAM_23LC512_EndTransfer
|
rcall RAM_23LC512_EndTransfer
|
||||||
sec
|
sec
|
||||||
RAM_23LC512_ReadPattern_ret:
|
RAM_23LC512_ReadPattern_ret:
|
||||||
|
pop r25
|
||||||
|
pop r24
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -221,13 +232,13 @@ RAM_23LC512_ReadPattern_ret:
|
|||||||
; @routine RAM_23LC512_ReadModeRegister
|
; @routine RAM_23LC512_ReadModeRegister
|
||||||
;
|
;
|
||||||
; @return r16 mode register
|
; @return r16 mode register
|
||||||
; @clobbers r17-r19, r23
|
; @clobbers r17, r23
|
||||||
|
|
||||||
RAM_23LC512_ReadModeRegister:
|
RAM_23LC512_ReadModeRegister:
|
||||||
ldi r16, RAM_23LC512_CMD_RDMR
|
ldi r16, RAM_23LC512_CMD_RDMR
|
||||||
rcall ram23LC512StartCommand
|
rcall ram23LC512StartCommand ; (r16, r17, r23)
|
||||||
clr r16
|
clr r16
|
||||||
bigcall SPISW_MasterExchangeByteMode0 ; (r17, r18, r19, r23)
|
bigcall SPISW_MasterExchangeByteMode0 ; r16=value (r17, r23)
|
||||||
push r16
|
push r16
|
||||||
rcall RAM_23LC512_EndTransfer
|
rcall RAM_23LC512_EndTransfer
|
||||||
pop r16
|
pop r16
|
||||||
@@ -241,16 +252,16 @@ RAM_23LC512_ReadModeRegister:
|
|||||||
;
|
;
|
||||||
; @param r16 command
|
; @param r16 command
|
||||||
; @param X address
|
; @param X address
|
||||||
; @clobbers r16-r19, r23
|
; @clobbers r16, r17, r23
|
||||||
|
|
||||||
ram23LC512StartTransfer:
|
ram23LC512StartTransfer:
|
||||||
rcall ram23LC512StartCommand
|
rcall ram23LC512StartCommand ; (r16, r17, r23)
|
||||||
|
|
||||||
; send address
|
; send address
|
||||||
mov r16, xh
|
mov r16, xh
|
||||||
bigcall SPISW_MasterExchangeByteMode0 ; (r17, r18, r19, r23)
|
bigcall SPISW_MasterExchangeByteMode0 ; (r16, r17, r23)
|
||||||
mov r16, xl
|
mov r16, xl
|
||||||
bigcall SPISW_MasterExchangeByteMode0 ; (r17, r18, r19, r23)
|
bigcall SPISW_MasterExchangeByteMode0 ; (r16, r17, r23)
|
||||||
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
@@ -261,11 +272,11 @@ ram23LC512StartTransfer:
|
|||||||
; @routine ram23LC512StartCommand
|
; @routine ram23LC512StartCommand
|
||||||
;
|
;
|
||||||
; @param r16 command
|
; @param r16 command
|
||||||
; @clobbers r16-r19, r23
|
; @clobbers r16, r17, r23
|
||||||
|
|
||||||
ram23LC512StartCommand:
|
ram23LC512StartCommand:
|
||||||
push r16
|
push r16
|
||||||
bigcall SPISW_MasterStart
|
bigcall SPISW_MasterStart ; (none)
|
||||||
pop r16
|
pop r16
|
||||||
nop
|
nop
|
||||||
sbi RAMCS_DDR, RAMCS_PIN ; CS: output
|
sbi RAMCS_DDR, RAMCS_PIN ; CS: output
|
||||||
@@ -273,7 +284,7 @@ ram23LC512StartCommand:
|
|||||||
nop
|
nop
|
||||||
|
|
||||||
; send command
|
; send command
|
||||||
bigcall SPISW_MasterExchangeByteMode0 ; (r17, r18, r19, r23)
|
bigcall SPISW_MasterExchangeByteMode0 ; (r16, r17, r23)
|
||||||
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|||||||
Reference in New Issue
Block a user