ButterflyMP3

mmc.h

Go to the documentation of this file.
00001 
00046 // MMC Hardware connections
00047 #define MMC_PORT        PORTE
00048 #define MMC_PIN         PINE
00049 #define MMC_DDR         DDRE
00050 #define MMC_CS          PE4
00051 #define SPI_PORT        PORTB
00052 #define SPI_DDR         DDRB
00053 #define SPI_SS          PB0
00054 #define SPI_SCK         PB1
00055 #define SPI_MOSI        PB2
00056 #define SPI_MISO        PB3
00057 
00058 // MMC commands
00059 #define MMC_GO_IDLE_STATE               0
00060 #define MMC_SEND_OP_COND                1
00061 #define MMC_SEND_CSD                    9
00062 #define MMC_SEND_CID                    10
00063 #define MMC_SEND_STATUS                 13
00064 #define MMC_SET_BLOCKLEN                16
00065 #define MMC_READ_SINGLE_BLOCK           17
00066 #define MMC_WRITE_BLOCK                 24
00067 #define MMC_PROGRAM_CSD                 27
00068 #define MMC_SET_WRITE_PROT              28
00069 #define MMC_CLR_WRITE_PROT              29
00070 #define MMC_SEND_WRITE_PROT             30
00071 #define MMC_TAG_SECTOR_START            32
00072 #define MMC_TAG_SECTOR_END              33
00073 #define MMC_UNTAG_SECTOR                34
00074 #define MMC_TAG_ERASE_GROUP_START       35
00075 #define MMC_TAG_ERARE_GROUP_END         36
00076 #define MMC_UNTAG_ERASE_GROUP           37
00077 #define MMC_ERASE                       38
00078 #define MMC_CRC_ON_OFF                  59
00079 
00080 // R1 Response bit-defines
00081 #define MMC_R1_BUSY                             0x80
00082 #define MMC_R1_PARAMETER                        0x40
00083 #define MMC_R1_ADDRESS                          0x20
00084 #define MMC_R1_ERASE_SEQ                        0x10
00085 #define MMC_R1_COM_CRC                          0x08
00086 #define MMC_R1_ILLEGAL_COM                      0x04
00087 #define MMC_R1_ERASE_RESET                      0x02
00088 #define MMC_R1_IDLE_STATE                       0x01
00089 
00090 // Data Start tokens
00091 #define MMC_STARTBLOCK_READ                     0xFE
00092 #define MMC_STARTBLOCK_WRITE                    0xFE
00093 #define MMC_STARTBLOCK_MWRITE                   0xFC
00094 
00095 // Data Stop tokens
00096 #define MMC_STOPTRAN_WRITE                      0xFD
00097 
00098 // Data Error Token values
00099 #define MMC_DE_MASK                             0x1F
00100 #define MMC_DE_ERROR                            0x01
00101 #define MMC_DE_CC_ERROR                         0x02
00102 #define MMC_DE_ECC_FAIL                         0x04
00103 #define MMC_DE_OUT_OF_RANGE                     0x04
00104 #define MMC_DE_CARD_LOCKED                      0x04
00105 
00106 // Data Response Token values
00107 #define MMC_DR_MASK                             0x1F
00108 #define MMC_DR_ACCEPT                           0x05
00109 #define MMC_DR_REJECT_CRC                       0x0B
00110 #define MMC_DR_REJECT_WRITE_ERROR               0x0D
00111 
00112 #ifndef MMC_C
00113 
00114 #include "types.h"
00115 extern uint8 mmc_sbuf[];
00116 extern uint8 mmc_scratch[]; 
00117 
00118 //
00119 // Prototypes
00120 //
00121 void SpiInit(void);                             // init AVR HW
00122 uint8 SpiByte(unsigned char byte);              // xmit/recv over SPI
00123 
00124 uint8 MMC_Reset(void);                          // init mmc
00125 uint16 MMC_Check(void);                         // check status
00126 uint8 MMC_Read(uint32 lba);
00127 
00128 // ... removed to save space
00129 //uint8 MMC_Write(uint32 lba);
00130 //uint8 MMC_Identify(void);             // get CID data
00131 //uint8 MMC_CardType(void);             // get CSD data
00132 //uint32 MMC_Capacity(void);            // get capacity in Bytes
00133 //uint8 MMC_Name(void);                 // get MMC Name
00134 //uint8 MMC_WriteProtect(uint8 set);
00135 //void MMC_Flush(void);
00136 
00137 
00138 
00139 BOOL MMC_Detect(void);
00140 #endif
00141 
00142 
 All Files Functions Variables Typedefs Enumerations Enumerator Defines