📄 spi.asm
字号:
;#########################;# SPI bus communication #;#########################;.equ CLK_SPI, 0x91 ; P1.1.equ DQ_SPI, 0x92 ; P1.2 .text .using 0.global spiout.local spiouLp, spiouEndspiout: ; Shift out a byte to the SPI, last significant bit first. ; CLK, DQ expected high on entry. Return with CLK high. ; Called with data to send in A. ; Destroys A. setb C ; stop markspiouLp:rrc a ; move bit into CY jz spiouEnd clr CLK_SPI ; drop clock mov DQ_SPI, C ; output bit nop setb CLK_SPI ; raise clock clr C sjmp spiouLp ; next bitspiouEnd: ret.global spiin.local spiinL spiin: ; Shift in a byte from the SPI, last significant bit first. ; CLK, DQ expected high on entry. Return with CLK high. ; Returns received data byte in A. mov a,#0x80 ; stop marker setb DQ_SPI ; make SPI Data Line an inputspiinL: clr CLK_SPI ; drop clock nop mov c, DQ_SPI ; input bit setb CLK_SPI ; raise clock rrc a ; move bit into byte jnc spiinL ; next bit ret ;; end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -