]> cloudbase.mooo.com Git - avrcpm.git/blobdiff - avr/mmc.asm
* I2C Support added
[avrcpm.git] / avr / mmc.asm
index f43af1c86a330a80857ba09adfd9f98b43b00798..38fdfe0e4bc638550a887760f060ce0912b74940 100644 (file)
 #define        RES_NOTRDY      3       /* 3: Not Ready */
 #define        RES_PARERR      4       /* 4: Invalid Parameter */
 
+
+#define SPI_MODE_0     (0<<CPOL)|(0<<CPHA)
+#define SPI_MODE_1     (0<<CPOL)|(1<<CPHA)
+#define SPI_MODE_2     (1<<CPOL)|(0<<CPHA)
+#define SPI_MODE_3     (1<<CPOL)|(1<<CPHA)
+#define SPI_MODE       SPI_MODE_0
+
 ;------------------------------------------------
 ; 
 .macro spi_clkslow
 .if MMC_DEBUG > 1
        printstring     "SPI_CLK_SLOW "
 .endif
-       ldi     temp,(1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<SPR0)     ;clk/128
+       ldi     temp,SPI_MODE|(1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<SPR0)    ;clk/128
        out     SPCR,temp
        out     SPSR,_0
 .endm
@@ -74,7 +81,7 @@
 .if MMC_DEBUG > 1
        printstring     "SPI_CLK_FAST "
 .endif
-       ldi     temp,(1<<SPE)|(1<<MSTR)                 ;clk/4
+       ldi     temp,SPI_MODE|(1<<SPE)|(1<<MSTR)                        ;clk/4
        out     SPCR,temp
 #if MMC_SPI2X
        ldi     temp,(1<<SPI2X)
@@ -564,6 +571,11 @@ mmc_rcv_dbg1:
        brne    mmc_rdex
        
        rcall   spi_rcvr                ;Shift in first byte.
+.if MMC_DEBUG > 3
+       printnewline
+       rcall   printhex
+       printstring     " "
+.endif
        out     SPDR,_255               ;Start shift in next byte.
 mmc_rcv_rl:
        sbiw    yl,1
@@ -571,11 +583,18 @@ mmc_rcv_rl:
        st      z+,temp
        spi_waitm
        in      temp,SPDR
+.if MMC_DEBUG > 3
+       rcall   printhex
+       printstring     " "
+.endif
        out     SPDR,_255
        rjmp    mmc_rcv_rl
 
 mmc_rcv_rle:
        st      z+,temp                 ;Store last byte in buffer 
+.if MMC_DEBUG > 3
+       printnewline
+.endif
        rcall   spi_wait                ;      while SPI module shifts in crc part1.
        rcall   spi_rcvr                ;Read second crc.