eris2010

Documentation: http://frombelow.net/projects/eris2010/
Clone: git clone https://git.frombelow.net/eris2010.git
Log | Files | Refs | README | LICENSE

sd.inc (775B)


      1 ;;; -*- asm -*-
      2 
      3 ;;; Copyright 2021 Gerd Beuster (gerd@frombelow.net). This is free
      4 ;;; software under the GNU GPL v3 license or any later version. See
      5 ;;; COPYING in the root directory for details.
      6 
      7 ;;; Macros for accessing SD cards
      8 
      9 .namespace sd
     10 	
     11 SEND_CMD .macro
     12 .if DEBUG	
     13 	#io.PRINTS "Sending CMD$"
     14 	lda cmd
     15 	sec
     16 	sbc #$40
     17 	jsr io.puth
     18 	#io.PRINTNL
     19 .endif
     20 	lda #<cmd
     21 	sta sd.data
     22 	lda #>cmd
     23 	sta sd.data+1
     24 	jsr sd.send_cmd
     25 	jmp cont_SEND_CMD
     26 cmd:	.byte \1
     27 cont_SEND_CMD:	
     28 	.endm
     29 
     30 	
     31 	
     32 RECEIVE .macro
     33 	ldx #\1
     34 loop_RECEIVE:
     35 	phx
     36 	jsr via.spi_get
     37 .if DEBUG	
     38 	pha
     39 	jsr io.puth
     40 	#io.PRINTS " "
     41 	pla
     42 .endif
     43 	plx
     44 	dex
     45 	bne loop_RECEIVE
     46 	pha
     47 .if DEBUG	
     48 	#io.PRINTNL
     49 .endif
     50 	;; Read non-existing dummy byte for snychronization
     51    	jsr via.spi_get_nonblocking
     52 	pla
     53 	.endm
     54 
     55 .endn