avr: use macros instead of costly calls for SPI on ILI9341.

This commit is contained in:
Martin Preuss
2026-01-24 01:03:31 +01:00
parent 2085ba6bbe
commit fdfc040d19
5 changed files with 79 additions and 24 deletions

View File

@@ -23,6 +23,7 @@
; @clobbers R16, R17, R20, R21, R22, R23, R24, R25
Display_FillRect:
#if 1
push r15
in r15, SREG
cli
@@ -42,9 +43,11 @@ Display_FillRect_loopH:
mov r25, r9 ; W high
Display_FillRect_loopW:
mov r16, r3
rcall SPIHW_MasterTransfer ; (R16)
; rcall SPIHW_MasterTransfer ; (R16)
M_SPIHW_MASTER_SEND_BYTE r16 ; (R16)
mov r16, r2
rcall SPIHW_MasterTransfer ; (R16)
; rcall SPIHW_MasterTransfer ; (R16)
M_SPIHW_MASTER_SEND_BYTE r16 ; (R16)
sbiw r25:r24, 1
brne Display_FillRect_loopW
mov r24, r22 ; remaining H low
@@ -58,6 +61,30 @@ Display_FillRect_loopW:
out SREG, r15
pop r15
ret
#else
push r15
in r15, SREG
cli
rcall ili9341BeginSpi ; (R16, R17)
rcall ili9341SetAddressWindow ; (R16, r20, r21)
mov r20, r8
mov r21, r9
mov r22, r10
mov r23, r11
bigcall Utils_Mulu16x16_32
mov r24, r16
mov r25, r17
rcall displaySendColor
sbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS high
rcall ili9341EndSpi
out SREG, r15
pop r15
ret
#endif
; @end
@@ -200,9 +227,11 @@ displaySendColor:
sbi ILI9341_DC_OUTPUT, ILI9341_DC_PIN ; D high (DATA)
displaySendColor_loop:
mov r16, r3
rcall SPIHW_MasterTransfer ; (R16)
; rcall SPIHW_MasterTransfer ; (R16)
M_SPIHW_MASTER_SEND_BYTE r16
mov r16, r2
rcall SPIHW_MasterTransfer ; (R16)
; rcall SPIHW_MasterTransfer ; (R16)
M_SPIHW_MASTER_SEND_BYTE r16
sbiw r25:r24, 1
brne displaySendColor_loop
sbi SPIHW_SS_OUTPUT, SPIHW_SS_PIN ; SS high
@@ -298,10 +327,12 @@ Display_BitBlit_loopH:
Display_BitBlit_loopW:
ld r18, X+ ; read color from X
ld r19, X+
mov r16, r19
rcall SPIHW_MasterTransfer ; (R16)
mov r16, r18
rcall SPIHW_MasterTransfer ; (R16)
; mov r16, r19
; rcall SPIHW_MasterTransfer ; (R16)
M_SPIHW_MASTER_SEND_BYTE r19
; mov r16, r18
; rcall SPIHW_MasterTransfer ; (R16)
M_SPIHW_MASTER_SEND_BYTE r18
sbiw r25:r24, 1
brne Display_BitBlit_loopW
mov r24, r22