Guest User

Untitled

a guest
Apr 4th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. ; ---------------------------------------------------------------------------
  2. ; spi send/receive routine - block, with CS
  3. ; low addr in A, high addr in Y, count in X
  4.  
  5. .proc _spi_txrx_block: near
  6. sta $fe
  7. sty $ff
  8. ldy #0
  9. lda #$fe ; lower cs0
  10. sta SPI0_BASE+SPICSR
  11. ssb_twt: lda SPI0_BASE+SPISR ; get tx status on first pass
  12. and #$10 ; test trdy
  13. beq ssb_twt ; loop until ready
  14. ssb_lp: lda ($fe),y ; get tx byte
  15. sta SPI0_BASE+SPITXDR ; send tx
  16. ssb_rwt: lda SPI0_BASE+SPISR ; get rx status
  17. and #$08 ; test rrdy
  18. beq ssb_rwt ; loop until ready
  19. lda SPI0_BASE+SPIRXDR ; get rx
  20. sta ($fe),y ; save rx byte
  21. iny
  22. dex
  23. bne ssb_lp ; back to tx - assume ready
  24. lda #$ff ; raise cs0
  25. sta SPI0_BASE+SPICSR
  26. rts
  27. .endproc
Advertisement
Add Comment
Please, Sign In to add comment