E:/Projects/AvrLib/include/Xmmc.h File Reference

#include "global.h"
#include "task.h"
#include "MessageQueue.h"

Include dependency graph for Xmmc.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
#define MMC_GO_IDLE_STATE   0
#define MMC_SEND_OP_COND   1
#define MMC_SEND_CSD   9
#define MMC_SEND_CID   10
#define MMC_SEND_STATUS   13
#define MMC_SET_BLOCKLEN   16
 Set number of bytes to transfer per block.
#define MMC_READ_SINGLE_BLOCK   17
 read a block
#define MMC_WRITE_BLOCK   24
 write a block
#define MMC_PROGRAM_CSD   27
#define MMC_SET_WRITE_PROT   28
#define MMC_CLR_WRITE_PROT   29
#define MMC_SEND_WRITE_PROT   30
#define MMC_TAG_SECTOR_START   32
#define MMC_TAG_SECTOR_END   33
#define MMC_UNTAG_SECTOR   34
#define MMC_TAG_ERASE_GROUP_START   35
 Sets beginning of erase group (mass erase).
#define MMC_TAG_ERARE_GROUP_END   36
 Sets end of erase group (mass erase).
#define MMC_UNTAG_ERASE_GROUP   37
 Untag (unset) erase group (mass erase).
#define MMC_ERASE   38
 Perform block/mass erase.
#define MMC_SEND_OP_COND_A   41
#define MMC_APP_CMD   55
#define MMC_CRC_ON_OFF   59
 Turns CRC check on/off.
#define MMC_R1_BUSY   0x80
 R1 response: bit indicates card is busy.
#define MMC_R1_PARAMETER   0x40
#define MMC_R1_ADDRESS   0x20
#define MMC_R1_ERASE_SEQ   0x10
#define MMC_R1_COM_CRC   0x08
#define MMC_R1_ILLEGAL_COM   0x04
#define MMC_R1_ERASE_RESET   0x02
#define MMC_R1_IDLE_STATE   0x01
#define MMC_R2_CSD_OVERWRITE   0x8000
#define MMC_R2_ERASE_PARAM   0x4000
#define MMC_R2_WP   0x2000
#define MMC_R2_ECC_FAILED   0x1000
#define MMC_R2_CC_FAILED   0x0800
#define MMC_R2_ERROR   0x0400
#define MMC_R2_WP_ERASESKIPPED   0x0200
#define MMC_R2_CARD_LOCKED   0x0100
#define MMC_STARTBLOCK_READ   0xFE
 when received from card, indicates that a block of data will follow
#define MMC_STARTBLOCK_WRITE   0xFE
 when sent to card, indicates that a block of data will follow
#define MMC_STARTBLOCK_MWRITE   0xFC
#define MMC_STOPTRAN_WRITE   0xFD
#define MMC_DE_MASK   0x1F
#define MMC_DE_ERROR   0x01
#define MMC_DE_CC_ERROR   0x02
#define MMC_DE_ECC_FAIL   0x04
#define MMC_DE_OUT_OF_RANGE   0x04
#define MMC_DE_CARD_LOCKED   0x04
#define MMC_DR_MASK   0x1F
#define MMC_DR_ACCEPT   0x05
#define MMC_DR_REJECT_CRC   0x0B
#define MMC_DR_REJECT_WRITE_ERROR   0x0D
#define MMC_CMD_RESET   0
#define MMC_CMD_RDSECTOR   1
#define MMC_CMD_WDSECTOR   2
#define MMC_CMD_STATUS   3
#define MMC_CMD_WRITE_FILE   4
MESSAGE_QUEUESDcardMSG
TCB Tmmc
void mmcInit (void)
u08 mmcReset (void)
u08 mmcSendCommand (u08 cmd, u32 arg)
u08 mmcRead (u32 sector, u08 *buffer)
u08 mmcWrite (u32 sector, u08 *buffer)
u08 mmcCommand (u08 cmd, u32 arg, char *b)
unsigned short mmcSendStatus (void)
u08 mmcSendSEND_OP_COND (u32 *ocr)
u08 mmcSendSetBlockLen (unsigned short len)
void MsgMMCReset (void)
void MsgMMCReadSector (unsigned long sector)
void MsgMMCWriteSector (unsigned long sector, char *b, int n)
void MsgMMCSendStatus (void)
void MsgMMCWriteTestFile (void)


Define Documentation

#define MMC_APP_CMD   55

Definition at line 85 of file Xmmc.h.

Referenced by mmcReset().

#define MMC_CLR_WRITE_PROT   29

Definition at line 75 of file Xmmc.h.

#define MMC_CMD_RDSECTOR   1

Definition at line 130 of file Xmmc.h.

Referenced by MMCTask(), and MsgMMCReadSector().

#define MMC_CMD_RESET   0

Definition at line 129 of file Xmmc.h.

Referenced by MMCTask(), and MsgMMCReset().

#define MMC_CMD_STATUS   3

Definition at line 132 of file Xmmc.h.

Referenced by MMCTask(), and MsgMMCSendStatus().

#define MMC_CMD_WDSECTOR   2

Definition at line 131 of file Xmmc.h.

Referenced by MMCTask(), and MsgMMCWriteSector().

#define MMC_CMD_WRITE_FILE   4

Definition at line 133 of file Xmmc.h.

Referenced by MMCTask(), and MsgMMCWriteTestFile().

#define MMC_CRC_ON_OFF   59

Turns CRC check on/off.

Definition at line 86 of file Xmmc.h.

#define MMC_DE_CARD_LOCKED   0x04

Definition at line 118 of file Xmmc.h.

#define MMC_DE_CC_ERROR   0x02

Definition at line 115 of file Xmmc.h.

#define MMC_DE_ECC_FAIL   0x04

Definition at line 116 of file Xmmc.h.

#define MMC_DE_ERROR   0x01

Definition at line 114 of file Xmmc.h.

#define MMC_DE_MASK   0x1F

Definition at line 113 of file Xmmc.h.

#define MMC_DE_OUT_OF_RANGE   0x04

Definition at line 117 of file Xmmc.h.

#define MMC_DR_ACCEPT   0x05

Definition at line 121 of file Xmmc.h.

Referenced by mmcWrite().

#define MMC_DR_MASK   0x1F

Definition at line 120 of file Xmmc.h.

Referenced by mmcWrite().

#define MMC_DR_REJECT_CRC   0x0B

Definition at line 122 of file Xmmc.h.

#define MMC_DR_REJECT_WRITE_ERROR   0x0D

Definition at line 123 of file Xmmc.h.

#define MMC_ERASE   38

Perform block/mass erase.

Definition at line 83 of file Xmmc.h.

#define MMC_GO_IDLE_STATE   0

Definition at line 65 of file Xmmc.h.

Referenced by mmcReset().

#define MMC_PROGRAM_CSD   27

Definition at line 73 of file Xmmc.h.

#define MMC_R1_ADDRESS   0x20

Definition at line 90 of file Xmmc.h.

Referenced by DecodeMMCIO(), and DecodeMMCResult().

#define MMC_R1_BUSY   0x80

R1 response: bit indicates card is busy.

Definition at line 88 of file Xmmc.h.

Referenced by DecodeMMCIO(), and DecodeMMCResult().

#define MMC_R1_COM_CRC   0x08

Definition at line 92 of file Xmmc.h.

Referenced by DecodeMMCIO(), and DecodeMMCResult().

#define MMC_R1_ERASE_RESET   0x02

Definition at line 94 of file Xmmc.h.

Referenced by DecodeMMCIO(), and DecodeMMCResult().

#define MMC_R1_ERASE_SEQ   0x10

Definition at line 91 of file Xmmc.h.

Referenced by DecodeMMCIO(), and DecodeMMCResult().

#define MMC_R1_IDLE_STATE   0x01

Definition at line 95 of file Xmmc.h.

Referenced by DecodeMMCIO(), and DecodeMMCResult().

#define MMC_R1_ILLEGAL_COM   0x04

Definition at line 93 of file Xmmc.h.

Referenced by DecodeMMCIO(), and DecodeMMCResult().

#define MMC_R1_PARAMETER   0x40

Definition at line 89 of file Xmmc.h.

Referenced by DecodeMMCIO(), and DecodeMMCResult().

#define MMC_R2_CARD_LOCKED   0x0100

Definition at line 104 of file Xmmc.h.

#define MMC_R2_CC_FAILED   0x0800

Definition at line 101 of file Xmmc.h.

#define MMC_R2_CSD_OVERWRITE   0x8000

Definition at line 97 of file Xmmc.h.

#define MMC_R2_ECC_FAILED   0x1000

Definition at line 100 of file Xmmc.h.

#define MMC_R2_ERASE_PARAM   0x4000

Definition at line 98 of file Xmmc.h.

#define MMC_R2_ERROR   0x0400

Definition at line 102 of file Xmmc.h.

#define MMC_R2_WP   0x2000

Definition at line 99 of file Xmmc.h.

Referenced by DecodeMMCStatus().

#define MMC_R2_WP_ERASESKIPPED   0x0200

Definition at line 103 of file Xmmc.h.

Referenced by DecodeMMCStatus().

#define MMC_READ_SINGLE_BLOCK   17

read a block

Definition at line 71 of file Xmmc.h.

Referenced by mmcRead().

#define MMC_SEND_CID   10

Definition at line 68 of file Xmmc.h.

#define MMC_SEND_CSD   9

Definition at line 67 of file Xmmc.h.

#define MMC_SEND_OP_COND   1

Definition at line 66 of file Xmmc.h.

#define MMC_SEND_OP_COND_A   41

Definition at line 84 of file Xmmc.h.

Referenced by mmcReset().

#define MMC_SEND_STATUS   13

Definition at line 69 of file Xmmc.h.

Referenced by mmcSendStatus().

#define MMC_SEND_WRITE_PROT   30

Definition at line 76 of file Xmmc.h.

#define MMC_SET_BLOCKLEN   16

Set number of bytes to transfer per block.

Definition at line 70 of file Xmmc.h.

Referenced by mmcReset().

#define MMC_SET_WRITE_PROT   28

Definition at line 74 of file Xmmc.h.

#define MMC_STARTBLOCK_MWRITE   0xFC

Definition at line 109 of file Xmmc.h.

#define MMC_STARTBLOCK_READ   0xFE

when received from card, indicates that a block of data will follow

Definition at line 107 of file Xmmc.h.

Referenced by mmcRead().

#define MMC_STARTBLOCK_WRITE   0xFE

when sent to card, indicates that a block of data will follow

Definition at line 108 of file Xmmc.h.

Referenced by mmcWrite().

#define MMC_STOPTRAN_WRITE   0xFD

Definition at line 111 of file Xmmc.h.

#define MMC_TAG_ERARE_GROUP_END   36

Sets end of erase group (mass erase).

Definition at line 81 of file Xmmc.h.

#define MMC_TAG_ERASE_GROUP_START   35

Sets beginning of erase group (mass erase).

Definition at line 80 of file Xmmc.h.

#define MMC_TAG_SECTOR_END   33

Definition at line 78 of file Xmmc.h.

#define MMC_TAG_SECTOR_START   32

Definition at line 77 of file Xmmc.h.

#define MMC_UNTAG_ERASE_GROUP   37

Untag (unset) erase group (mass erase).

Definition at line 82 of file Xmmc.h.

#define MMC_UNTAG_SECTOR   34

Definition at line 79 of file Xmmc.h.

#define MMC_WRITE_BLOCK   24

write a block

Definition at line 72 of file Xmmc.h.

Referenced by mmcWrite().


Function Documentation

u08 mmcCommand ( u08  cmd,
u32  arg,
char *  b 
)

Internal command function. Issues a generic MMC command as specified by cmd and arg.

Definition at line 305 of file Xmmc.c.

References XspiTransfer(), and XspiTransferByte().

Referenced by mmcRead(), mmcSendCommand(), mmcSendStatus(), and mmcWrite().

void mmcInit ( void   ) 

Initialize AVR<->MMC hardware interface. Prepares hardware for MMC access.

Definition at line 53 of file Xmmc.c.

References ActiveTasks, CreateTask(), Insert(), MMCTask(), MqInit(), and XSPI_CLR_CE.

u08 mmcRead ( u32  sector,
u08 buffer 
)

Read 512-byte sector from card to buffer Returns zero if successful.

Definition at line 219 of file Xmmc.c.

References free, malloc, MMC_READ_SINGLE_BLOCK, MMC_STARTBLOCK_READ, mmcCommand(), wprintw(), XSPI_CLR_CE, XSPI_SET_CE, XspiTransfer(), and XspiTransferByte().

Referenced by disk_read(), and MMCTask().

u08 mmcReset ( void   ) 

Initialize the card and prepare it for use. Returns zero if successful.

Definition at line 82 of file Xmmc.c.

References free, malloc, MMC_APP_CMD, MMC_GO_IDLE_STATE, MMC_SEND_OP_COND_A, MMC_SET_BLOCKLEN, mmcResponse(), TimeDelay(), wprintw(), XSPI_CLR_CE, XSPI_SET_CE, XspiTransfer(), and XspiTransferByte().

Referenced by disk_initialize(), and MMCTask().

u08 mmcSendCommand ( u08  cmd,
u32  arg 
)

Send card an MMC command. Returns R1 result code.

Definition at line 205 of file Xmmc.c.

References free, malloc, mmcCommand(), XSPI_CLR_CE, and XSPI_SET_CE.

u08 mmcSendSEND_OP_COND ( u32 ocr  ) 

u08 mmcSendSetBlockLen ( unsigned short  len  ) 

unsigned short mmcSendStatus ( void   ) 

Definition at line 187 of file Xmmc.c.

References free, malloc, MMC_SEND_STATUS, mmcCommand(), XSPI_CLR_CE, XSPI_SET_CE, and XspiTransferByte().

Referenced by disk_status(), and MMCTask().

u08 mmcWrite ( u32  sector,
u08 buffer 
)

Write 512-byte sector from buffer to card Returns zero if successful.

Definition at line 263 of file Xmmc.c.

References free, malloc, MMC_DR_ACCEPT, MMC_DR_MASK, MMC_STARTBLOCK_WRITE, MMC_WRITE_BLOCK, mmcCommand(), wprintw(), XSPI_CLR_CE, XSPI_SET_CE, XspiTransfer(), and XspiTransferByte().

Referenced by disk_write(), and MMCTask().

void MsgMMCReadSector ( unsigned long  sector  ) 

Definition at line 459 of file Xmmc.c.

References MMC_CMD_RDSECTOR, MqPut(), _msg::MsgCmd, NewMSG(), and _msg::Payload.

void MsgMMCReset ( void   ) 

Definition at line 450 of file Xmmc.c.

References MMC_CMD_RESET, MqPut(), _msg::MsgCmd, and NewMSG().

void MsgMMCSendStatus ( void   ) 

Definition at line 487 of file Xmmc.c.

References MMC_CMD_STATUS, MqPut(), _msg::MsgCmd, and NewMSG().

void MsgMMCWriteSector ( unsigned long  sector,
char *  b,
int  n 
)

Definition at line 471 of file Xmmc.c.

References memcpy(), MMC_CMD_WDSECTOR, MqPut(), _msg::MsgCmd, NewMSG(), and _msg::Payload.

void MsgMMCWriteTestFile ( void   ) 

Definition at line 496 of file Xmmc.c.

References MMC_CMD_WRITE_FILE, MqPut(), _msg::MsgCmd, and NewMSG().


Variable Documentation

Definition at line 47 of file Xmmc.c.

Definition at line 48 of file Xmmc.c.


Generated on Sun Aug 31 13:30:54 2008 for FrankenRTOS by  doxygen 1.5.6