Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ---------------------------------------------------------------------------
- ; spi send/receive routine - block, with CS
- ; low addr in A, high addr in Y, count in X
- .proc _spi_txrx_block: near
- sta $fe
- sty $ff
- ldy #0
- lda #$fe ; lower cs0
- sta SPI0_BASE+SPICSR
- ssb_twt: lda SPI0_BASE+SPISR ; get tx status on first pass
- and #$10 ; test trdy
- beq ssb_twt ; loop until ready
- ssb_lp: lda ($fe),y ; get tx byte
- sta SPI0_BASE+SPITXDR ; send tx
- ssb_rwt: lda SPI0_BASE+SPISR ; get rx status
- and #$08 ; test rrdy
- beq ssb_rwt ; loop until ready
- lda SPI0_BASE+SPIRXDR ; get rx
- sta ($fe),y ; save rx byte
- iny
- dex
- bne ssb_lp ; back to tx - assume ready
- lda #$ff ; raise cs0
- sta SPI0_BASE+SPICSR
- rts
- .endproc
Advertisement
Add Comment
Please, Sign In to add comment