📄 drv_sam_spi.s
字号:
;/*------------------------------------------------------------------------------
;[BASIC]
;{
; [FILENAME] drv_sam_spi.s
; [CONTENT] this file complete to SPI Timing for Samsung
; [AUTHOR] xucao
; [VERSION] 01.0.00.051124
; [COMPANY] APLUS COMMUNICATION TECHNOLOGY (BeiJing) CO.,LTD
;}
;
;[MOD]
;{
; 01.0.00.051220:
; 1.Create initial version
;}
;------------------------------------------------------------------------------*/
; Pin map of SPI
; CS <--> GPC7
; CLK <--> GPC5
; SDI <--> GPC6
LCDCTL_IOSCR0_ADDR EQU 0x14000300
LCDCTL_IOSCR1_ADDR EQU 0x14000302
LCDCTL_IOSCR2_ADDR EQU 0x14000304
LCDCTL_IOSCR3_ADDR EQU 0x14000306
LCDCTL_IOPDCR0_ADDR EQU 0x14000308
LCDCTL_IOPDCR1_ADDR EQU 0x1400030A
LCDCTL_IOSCR4_ADDR EQU 0x1400030C
LCDCTL_IOSCR5_ADDR EQU 0x1400030E
AREA SAMSPI, CODE, READONLY
ENTRY
EXPORT spi_send_data
IMPORT GPIOSTATE
spi_send_data
STMFD SP!,{r2-r7,r14} ;save the register of this code using
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ldr r6,=LCDCTL_IOSCR4_ADDR ;r6 is the state register address of the gpio
ldr r7,=GPIOSTATE
mov r4,#0x08 ;send the data bit count
ldrh r5,[r7] ;[r6] ;r5 is the gpio state data
bic r5,r5,#0x08 ;set cs to low
strh r5,[r6]
nop
Loop
and r2,r0,#0x80 ;first send the r0
cmp r2,#0
bne sendhigh
bic r5,r5,#0x6 ;set clock,data to low
nop
strh r5,[r6]
b BitCom
sendhigh
bic r5,r5,#0x04 ;set clock to low
orr r5,r5,#0x02 ;set data to high
strh r5,[r6]
nop
BitCom
nop
nop
nop
mov r0,r0,LSL #1
sub r4,r4,#1
orr r5,r5,#0x04 ;set the clock to high
cmp r4,#0
strh r5,[r6]
bne Loop
;start to send the 16 bits data
mov r4,#16 ;send the data bit count
Loop1
;ldr r5,[r6]
and r2,r1,#0x8000 ;first send the r0
cmp r2,#0
bne sendhigh1
bic r5,r5,#0x6 ;set the clock,data to low
nop
strh r5,[r6]
b BitCom1
sendhigh1
bic r5,r5,#0x04 ;set clock to low
orr r5,r5,#0x02 ;set data to high
strh r5,[r6]
nop
BitCom1
nop
nop
nop
mov r1,r1,LSL #1
sub r4,r4,#1
orr r5,r5,#0x04 ;set the clock to high
cmp r4,#0
strh r5,[r6]
bne Loop1
orr r5,r5,#0x08 ;set cs to high
strh r5,[r6]
LDMFD SP!,{r2-r7,pc} ;save the register of this code using
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -