Collaboration diagram for Multimedia Card Driver:
![]() |
Data Structures | |
struct | _MMCIFC |
Low level access information structure. More... | |
struct | _MMC_CID |
Multimedia card identification register. More... | |
struct | _MMC_CSD |
Multimedia card identification register. More... | |
Control Codes | |
#define | MMCARD_GETSTATUS 0x2001 |
Retrieve card status. | |
#define | MMCARD_GETOCR 0x2002 |
Retrieve operation condition register. | |
#define | MMCARD_GETCID 0x2003 |
Retrieve card identification. | |
#define | MMCARD_GETCSD 0x2004 |
Retrieve card specific data. | |
Defines | |
#define | MMCMD_HOST 0x40 |
#define | MMCMD_RESET_CRC 0x95 |
#define | MMCMD_GO_IDLE_STATE 0 |
Reset card to idle state. | |
#define | MMCMD_SEND_OP_COND 1 |
Activate card's initialization process. | |
#define | MMCMD_ALL_SEND_CID 2 |
Send operation condition register. | |
#define | MMCMD_SEND_RELATIVE_ADDR 3 |
Assign relative card address. | |
#define | MMCMD_SELECT_CARD 7 |
Assign relative card address. | |
#define | MMCMD_SEND_CSD 9 |
Query card's CSD. | |
#define | MMCMD_SEND_CID 10 |
Query card's CID. | |
#define | MMCMD_STOP_TRANSMISSION 12 |
Stop multiple block transmission. | |
#define | MMCMD_SEND_STATUS 13 |
Query card's status register. | |
#define | MMCMD_SET_BLOCKLEN 16 |
Select block length for following read/write commands. | |
#define | MMCMD_READ_SINGLE_BLOCK 17 |
Initiate single block read. | |
#define | MMCMD_READ_MULTIPLE_BLOCK 18 |
Initiate continuous block read. | |
#define | MMCMD_WRITE_BLOCK 24 |
Initiate single block write. | |
#define | MMCMD_WRITE_MULTIPLE_BLOCK 25 |
Initiate continuous block write. | |
#define | MMCMD_PROGRAM_CSD 27 |
Initiate programming of programmable CSD bits. | |
#define | MMCMD_SET_WRITE_PROTECT 28 |
Enable card's optional write protection. | |
#define | MMCMD_CLR_WRITE_PROTECT 29 |
Disable card's write protection. | |
#define | MMCMD_SEND_WRITE_PROTECT 30 |
Query card's write protect status. | |
#define | MMCMD_TAG_ERASE_GROUP_START 35 |
Set address of the first erase group. | |
#define | MMCMD_TAG_ERASE_GROUP_END 36 |
Set address of the last erase group. | |
#define | MMCMD_ERASE 38 |
Erase previously selected sectors. | |
#define | MMCMD_LOCK_UNLOCK 42 |
Set/clear password or lock/unlock the card. | |
#define | MMCMD_READ_OCR 58 |
Query card's operating condition register. | |
#define | MMCMD_CRC_ON_OFF 59 |
Enable or disable CRC mode. | |
#define | MMR1_IDLE_STATE 0x00 |
Card is idle. | |
#define | MMR1_NOT_IDLE 0x01 |
Card is busy. | |
#define | MMR1_ERASE_RESET 0x02 |
Erase sequence was cleared before execution. | |
#define | MMR1_ILLEGAL_COMMAND 0x04 |
Illegal command code detected. | |
#define | MMR1_COM_CRC_ERROR 0x08 |
Bad command CRC detected. | |
#define | MMR1_ERASE_SEQ_ERROR 0x10 |
Bad erase sequence. | |
#define | MMR1_ADDRESS_ERROR 0x20 |
Misaligned address did not match block length. | |
#define | MMR1_PARAMETER_ERROR 0x40 |
Command parameter is out of range. | |
#define | MMR2_CARD_LOCKED 0x01 |
Card is locked. | |
#define | MMR2_WP_ERASE_SKIP 0x02 |
Erasing write protected sector or password error. | |
#define | MMR2_ERROR 0x04 |
General or unknown error occured. | |
#define | MMR2_CC_ERROR 0x08 |
Internal card controller error. | |
#define | MMR2_ECC_FAILED 0x10 |
Bad internal ECC. | |
#define | MMR2_WP_VIOLATION 0x20 |
Failed to write to protected block. | |
#define | MMR2_ERASE_PARAMETER 0x40 |
Invalid erase parameter. | |
#define | MMR2_OUT_OF_RANGE 0x80 |
Command parameter is out of range. | |
#define | MMCSR_OUT_OF_RANGE 0x80000000 |
#define | MMCSR_ADDRESS_ERROR 0x40000000 |
#define | MMCSR_BLOCK_LEN_ERROR 0x20000000 |
#define | MMCSR_ERASE_SEQ_ERROR 0x10000000 |
#define | MMCSR_ERASE_PARAM 0x08000000 |
#define | MMCSR_WP_VIOLATION 0x04000000 |
#define | MMCSR_COM_CRC_ERROR 0x00800000 |
#define | MMCSR_ILLEGAL_COMMAND 0x00400000 |
#define | MMCSR_ERROR 0x00080000 |
#define | MMCSR_CIDCSD_OVERWRITE 0x00010000 |
#define | MMCSR_WP_ERASE_SKIP 0x00008000 |
#define | MMCSR_CARD_ECC_DISABLED 0x00004000 |
#define | MMCSR_ERASE_RESET 0x00002000 |
#define | MMCSR_STATE_MASK 0x00001E00 |
#define | MMCSR_READY_FOR_DATA 0x00000100 |
#define | MMCSR_IS_IDLE 0x00000000 |
#define | MMCSR_IS_READY 0x00000200 |
#define | MMCSR_IS_IDENT 0x00000400 |
#define | MMCSR_IS_STBY 0x00000600 |
#define | MMCSR_IS_TRAN 0x00000800 |
#define | MMCSR_IS_DATA 0x00000A00 |
#define | MMCSR_IS_RCV 0x00000C00 |
#define | MMCSR_IS_PRG 0x00000E00 |
#define | MMCSR_IS_DIS 0x00001000 |
#define | MMDR_ACCEPTED |
#define | MMDR_CRC_ERROR |
#define | MMDR_WRITE_ERROR |
#define | MMCERR_TIMEOUT 0x00000001 |
#define | MMCOP_NBUSY 0x80000000 |
#define | MMCARD_CIDR_SIZE 16 |
Number of bytes in the CID register. | |
#define | MMCARD_CSDR_SIZE 16 |
Number of bytes in the CSD register. | |
#define | MMCARD_OCR_SIZE 32 |
Number of bytes in the operating condition register. | |
#define | MMC_BLOCK_SIZE 512 |
Block size. | |
#define | MMC_MAX_INIT_POLLS 512 |
Card init timeout. | |
#define | MMC_MAX_RESET_POLLS 255 |
Card reset timeout. | |
#define | MMC_MAX_WRITE_POLLS 1024 |
Card write timeout. | |
#define | MMC_MAX_WRITE_RETRIES 32 |
Card write retries. | |
#define | MMC_MAX_READ_RETRIES 8 |
Card read retries. | |
#define | MMC_MAX_REG_POLLS 512 |
Register read timeout. | |
#define | MMC_MAX_CMDACK_POLLS 1024 |
Command acknowledge timeout. | |
#define | MMC_MAX_R1_POLLS 1024 |
R1 response timeout. | |
Typedefs | |
typedef _MMCIFC | MMCIFC |
Low level access information structure. | |
typedef _MMC_CID | MMC_CID |
Multimedia card identification register. | |
typedef _MMC_CSD | MMC_CSD |
Multimedia card identification register. | |
typedef _MMCFCB | MMCFCB |
Local multimedia card mount information. | |
Functions | |
int | MmCardBlockRead (NUTFILE *nfp, void *buffer, int num) |
Read data blocks from a mounted partition. | |
int | MmCardBlockWrite (NUTFILE *nfp, CONST void *buffer, int num) |
Write data blocks to a mounted partition. | |
int | MmCardBlockWrite_P (NUTFILE *nfp, PGM_P buffer, int num) |
Write data blocks from program space to a mounted partition. | |
NUTFILE * | MmCardMount (NUTDEVICE *dev, CONST char *name, int mode, int acc) |
Mount a partition. | |
int | MmCardUnmount (NUTFILE *nfp) |
Unmount a previously mounted partition. | |
int | MmCardIOCtl (NUTDEVICE *dev, int req, void *conf) |
Perform MMC control functions. | |
int | MmCardDevInit (NUTDEVICE *dev) |
Initialize high level MMC driver. |
#define MMCMD_GO_IDLE_STATE 0 |
#define MMCMD_SEND_OP_COND 1 |
#define MMCMD_ALL_SEND_CID 2 |
#define MMCMD_SEND_RELATIVE_ADDR 3 |
#define MMCMD_SEND_CSD 9 |
#define MMCMD_SEND_CID 10 |
#define MMCMD_STOP_TRANSMISSION 12 |
#define MMCMD_SEND_STATUS 13 |
#define MMCMD_SET_BLOCKLEN 16 |
#define MMCMD_READ_SINGLE_BLOCK 17 |
#define MMCMD_READ_MULTIPLE_BLOCK 18 |
#define MMCMD_WRITE_MULTIPLE_BLOCK 25 |
#define MMCMD_PROGRAM_CSD 27 |
#define MMCMD_SET_WRITE_PROTECT 28 |
#define MMCMD_CLR_WRITE_PROTECT 29 |
#define MMCMD_SEND_WRITE_PROTECT 30 |
#define MMCMD_TAG_ERASE_GROUP_START 35 |
#define MMCMD_TAG_ERASE_GROUP_END 36 |
#define MMCMD_LOCK_UNLOCK 42 |
#define MMCMD_READ_OCR 58 |
Query card's operating condition register.
Definition at line 158 of file mmcard.h.
Referenced by MmCardIOCtl().
#define MMCMD_CRC_ON_OFF 59 |
#define MMR1_IDLE_STATE 0x00 |
#define MMR1_ERASE_RESET 0x02 |
#define MMR1_ILLEGAL_COMMAND 0x04 |
#define MMR1_ADDRESS_ERROR 0x20 |
#define MMR1_PARAMETER_ERROR 0x40 |
#define MMR2_WP_ERASE_SKIP 0x02 |
#define MMR2_WP_VIOLATION 0x20 |
#define MMR2_OUT_OF_RANGE 0x80 |
#define MMCARD_CIDR_SIZE 16 |
#define MMCARD_CSDR_SIZE 16 |
#define MMCARD_OCR_SIZE 32 |
#define MMCARD_GETSTATUS 0x2001 |
#define MMCARD_GETOCR 0x2002 |
Retrieve operation condition register.
Definition at line 253 of file mmcard.h.
Referenced by MmCardIOCtl().
#define MMCARD_GETCID 0x2003 |
#define MMCARD_GETCSD 0x2004 |
#define MMC_BLOCK_SIZE 512 |
#define MMC_MAX_INIT_POLLS 512 |
#define MMC_MAX_RESET_POLLS 255 |
#define MMC_MAX_WRITE_POLLS 1024 |
#define MMC_MAX_WRITE_RETRIES 32 |
#define MMC_MAX_READ_RETRIES 8 |
Card read retries.
Max. number of retries while reading.
Definition at line 162 of file mmcard.c.
Referenced by MmCardBlockRead(), and MmCardBlockWrite().
#define MMC_MAX_REG_POLLS 512 |
#define MMC_MAX_CMDACK_POLLS 1024 |
#define MMC_MAX_R1_POLLS 1024 |
typedef struct _MMCFCB MMCFCB |
Local multimedia card mount information.
int MmCardBlockRead | ( | NUTFILE * | nfp, | |
void * | buffer, | |||
int | num | |||
) |
Read data blocks from a mounted partition.
Applications should not call this function directly, but use the stdio interface.
nfp | Pointer to a NUTFILE structure, obtained by a previous call to MmCardMount(). | |
buffer | Pointer to the data buffer to fill. | |
num | Maximum number of blocks to read. However, reading multiple blocks is not yet supported by this driver. |
Definition at line 577 of file mmcard.c.
References MMC_MAX_READ_RETRIES, _MMCIFC::mmcifc_cd, _NUTFILE::nf_dev, and _NUTFILE::nf_fcb.
int MmCardBlockWrite | ( | NUTFILE * | nfp, | |
CONST void * | buffer, | |||
int | num | |||
) |
Write data blocks to a mounted partition.
Applications should not call this function directly, but use the stdio interface.
nfp | Pointer to a NUTFILE structure, obtained by a previous call to MmCardMount(). | |
buffer | Pointer to the data to be written. | |
num | Maximum number of blocks to write. However, writing multiple blocks is not yet supported by this driver. |
Definition at line 630 of file mmcard.c.
References MMC_MAX_READ_RETRIES, _MMCIFC::mmcifc_cd, _NUTFILE::nf_dev, and _NUTFILE::nf_fcb.
int MmCardBlockWrite_P | ( | NUTFILE * | nfp, | |
PGM_P | buffer, | |||
int | num | |||
) |
Write data blocks from program space to a mounted partition.
This function is not yet implemented and will always return -1.
Similar to MmCardBlockWrite() except that the data is located in program memory.
Applications should not call this function directly, but use the stdio interface.
nfp | File pointer to a previously opened device. | |
buffer | Pointer to the data bytes in program space to be written. | |
num | Maximum number of blocks to write. However, writing multiple blocks is not yet supported by this driver. |
Mount a partition.
Nut/OS doesn't provide specific routines for mounting. Instead routines for opening files are used.
Applications should not directly call this function, but use the high level stdio routines for opening a file.
dev | Pointer to the MMC device. | |
name | Partition number followed by a slash followed by a name of the file system device. Both items are optional. If no file system driver name is given, the first file system driver found in the list of registered devices will be used. If no partition number is specified or if partition zero is given, the first active primary partition will be used. | |
mode | Opening mode. Currently ignored, but should be used for compatibility with future enhancements. | |
acc | File attributes, ignored. |
Definition at line 719 of file mmcard.c.
References atoi(), _NUTDEVICE::dev_icb, _NUTDEVICE::dev_name, _NUTDEVICE::dev_next, _NUTDEVICE::dev_type, ENODEV, errno, IFTYP_FS, _MMCIFC::mmcifc_cd, nutDeviceList, NUTFILE_EOF, and strcmp().
int MmCardUnmount | ( | NUTFILE * | nfp | ) |
Unmount a previously mounted partition.
Applications should not directly call this function, but use the high level stdio routines for closing a previously opened file.
Definition at line 840 of file mmcard.c.
References _NUTDEVICE::dev_icb, FS_VOL_UNMOUNT, _MMCIFC::mmcifc_cd, _NUTFILE::nf_dev, _NUTFILE::nf_fcb, and NutHeapFree().
int MmCardIOCtl | ( | NUTDEVICE * | dev, | |
int | req, | |||
void * | conf | |||
) |
Perform MMC control functions.
This function is called by the ioctl() function of the C runtime library. Applications should not directly call this function.
dev | Identifies the device that receives the device-control function. | |
req | Requested control function. May be set to one of the following constants: | |
conf | Points to a buffer that contains any data required for the given control function or receives data from that function. |
Definition at line 934 of file mmcard.c.
References _NUTDEVICE::dev_icb, MMCARD_GETCID, MMCARD_GETCSD, MMCARD_GETOCR, MMCARD_GETSTATUS, _MMCIFC::mmcifc_cd, MMCMD_READ_OCR, MMCMD_SEND_CID, MMCMD_SEND_CSD, MMCMD_SEND_STATUS, MMR1_IDLE_STATE, _NUTFILE::nf_fcb, NUTBLKDEV_INFO, NUTBLKDEV_MEDIAAVAIL, NUTBLKDEV_MEDIACHANGE, NUTBLKDEV_SEEK, NutEventPost(), NutEventWait(), _BLKPAR_INFO::par_blkbp, _BLKPAR_SEEK::par_blknum, _BLKPAR_INFO::par_blksz, _BLKPAR_INFO::par_nblks, _BLKPAR_SEEK::par_nfp, and _BLKPAR_INFO::par_nfp.
int MmCardDevInit | ( | NUTDEVICE * | dev | ) |
Initialize high level MMC driver.
Applications should not directly call this function. It is automatically executed during during device registration by NutRegisterDevice().
dev | Identifies the device to initialize. |