📄 spi.s
字号:
.module spi.c
.area text(rom, con, rel)
.dbfile F:\dujiang\费显动态LED屏\下位机程序\spi.c
.dbfunc e SpiWriteByte _SpiWriteByte fV
; byte -> R16
.even
_SpiWriteByte::
.dbline -1
.dbline 15
; #include <iom64v.h> // change to the appropriate header file
; #include "spi.h"
;
;
;
; /* spi_init function should be generated using the AppBuilder
; */
;
; /*
; ** SpiWriteByte() writes a byte to the SPI and waits until
; ** it has been transmitted. This function doesn't
; ** return any value back.
; */
; void SpiWriteByte(unsigned char byte)
; {
.dbline 16
; SPDR = byte;
out 0xf,R16
L2:
.dbline 17
L3:
.dbline 17
; while (!(SPSR & 0x80));
sbis 0xe,7
rjmp L2
.dbline 18
; byte = SPDR;
in R16,0xf
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbsym r byte 16 c
.dbend
.dbfunc e SpiReadByte _SpiReadByte fc
.even
_SpiReadByte::
.dbline -1
.dbline 28
; }
;
; /*
; ** SpiReadByte() first writes a byte (a dummy, since
; ** that byte is to generate clock signals to "poll" home
; ** the byte from the slave. The function returns the
; ** received byte.
; */
; unsigned char SpiReadByte(void)
; {
.dbline 29
; SPDR = 0x00;
clr R2
out 0xf,R2
L6:
.dbline 30
L7:
.dbline 30
; while (!(SPSR & 0x80));
sbis 0xe,7
rjmp L6
.dbline 31
; return SPDR;
in R16,0xf
.dbline -2
L5:
.dbline 0 ; func end
ret
.dbend
.dbfunc e SpiReadDataReg _SpiReadDataReg fc
.even
_SpiReadDataReg::
.dbline -1
.dbline 40
; }
;
; /*
; ** SpiReadDataReg() reads the last byte in the SPI register
; ** without any clock signals generated. Could be used
; ** as reading the last byte received.
; */
; unsigned char SpiReadDataReg(void)
; {
.dbline 41
; return SPDR;
in R16,0xf
.dbline -2
L9:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 44
; }
; void main(void)
; {
.dbline 45
; SpiReadDataReg();
xcall _SpiReadDataReg
L11:
.dbline 46
L12:
.dbline 46
xjmp L11
X0:
.dbline -2
L10:
.dbline 0 ; func end
ret
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -