📄 mmcsd270.h
字号:
/*
DM270 ARM Evaluation Software
(c)Texas Instruments 2003
*/
/** \defgroup MMCSD MMC/SD module*/
/*@{*/
/** \file mmcsd270.h
\brief MMC/SD module related APIs
Also refer to DM270 register manual for details
*/
#ifndef _MMCSD270_H_
#define _MMCSD270_H_
#include <system/armsys270.h>
#define MMCSD_GET_WORD() MMCSD_RGET(MMCDRR)
#define MMCSD_SET_WORD(word16) MMCSD_RSET(MMCDXR, (word16) )
/**
\brief Endianness Select
*/
typedef enum {
MMCSD_LITTLE_ENDIAN, ///< Little Endian Selection
MMCSD_BIG_ENDIAN ///< Big Endian Selection
} MMCSD_ENDIAN;
/**
\brief Data Bus Width
*/
typedef enum {
MMCSD_DATA_BUS_1, ///< Data bus has 1 bit
MMCSD_DATA_BUS_4 ///< Data bus has 4 bits
} MMCSD_DATA_BUS_WIDTH;
/**
\brief DAT3 Edge Detection select
*/
typedef enum {
MMCSD_DAT3_DISABLE, ///< DAT3 edge detection is disabled
MMCSD_DAT3_RISE, ///< DAT3 rising edge detection is enabled
MMCSD_DAT3_FALL, ///< DAT3 falling edge detection is enabled
MMCSD_DAT3_BOTH ///< DAT3 both edge detection is enabled
} MMCSD_DAT3_DETECT;
/**
\brief Direction of DMA Transfer
*/
typedef enum {
MMCSD_FROM_MMC, ///< MMCIF to SDRAM
MMCSD_TO_MMC ///< SDRAM to MMCIF
} MMCSD_TRANSFER_DIRECTION;
/**
\brief MMCSD Controller Configuration parameters
*/
typedef struct {
MMCSD_ENDIAN writeEndian; ///< Endian select enable while writing
MMCSD_ENDIAN readEndian; ///< Endian select enable while reading
MMCSD_DAT3_DETECT dat3Detect; ///< DAT3 Edge detection
BOOL spiModeEnable; ///< SPI mode, TRUE:Enable SPI Mode, FALSE:Enable Native Mode
BOOL csEnable; ///< Card Select enable when writing, TRUE:CS output is LOW, FALSE: CS output is HIGH. Valid Only in SPI mode
BOOL spiCrcErrCheckEnable; ///< CRC Error check enabled, TRUE:Enable CRC check, FALSE:Disable CRC check. Valid Only in SPI mode
MMCSD_DATA_BUS_WIDTH busWidth; ///< Data bus width, Only in Native mode, MMCSD_DATA_BUS_1:1 bit data bus, MMCSD_DATA_BUS_4:4 bit data bus
Uint16 timeoutResponse; ///< Timeout value for response, range 0 to 255 MMC CLK clock cycles for Native mode, for SPI mode timeout value is equal to this value multiplied by 8 MMC CLK clock cycles
Uint16 timeoutRead; ///< Time out value for data read, range from 0 to 65535 MMC CLK clock cycles in native mode, for SPI mode timeout value is equal to this value multiplied by 8 MMC CLK clock cycles
} MMCSD_ConfigData;
/**
\brief Interrupt Enable/disable mask for MMCSD interrupts
*/
typedef struct {
BOOL datedIntEnable; ///< TRUE:Enable, FALSE:disable
BOOL drRdyIntEnable; ///< TRUE:Enable, FALSE:disable
BOOL dxRdyIntEnable; ///< TRUE:Enable, FALSE:disable
BOOL spiErrIntEnable; ///< TRUE:Enable, FALSE:disable
BOOL crcErrReadIntEnable; ///< TRUE:Enable, FALSE:disable
BOOL crcErrResponseIntEnable; ///< TRUE:Enable, FALSE:disable
BOOL crcErrWriteIntEnable; ///< TRUE:Enable, FALSE:disable
BOOL timeoutResponseIntEnable;///< TRUE:Enable, FALSE:disable
BOOL timeoutReadIntEnable; ///< TRUE:Enable, FALSE:disable
BOOL rspDneIntEnable; ///< TRUE:Enable, FALSE:disable
BOOL bsyDneIntEnable; ///< TRUE:Enable, FALSE:disable
BOOL datDneIntEnable; ///< TRUE:Enable, FALSE:disable
} MMCSD_IntMode;
typedef struct {
Uint16 response[8]; ///< Response of the command
Uchar dataResponse; ///< Data response
Uchar errorToken; ///< Error Token
Uchar commandIdk; ///< Command Index
} MMCSD_ResponseData;
typedef struct {
MMCSD_TRANSFER_DIRECTION direction; ///< Direction of transfer, MMCSD_FROM_MMC:MMC to SDRAM, MMCSD_TO_MMC:SDRAM to MMC
BOOL wordSwapEnable; ///< TRUE:Enable word swap, FALSE:Disable word swap
BOOL timeoutIntEnable; ///< TRUE:Enable Timeout interrupt, FALSE:Disable timeout interrupt
Uint16 timeoutValue; ///< timeout value range 0 to 65535 MMC CLK cycles
Uint32 sdramAddress; ///< Absolute SDRAM address for DMA transfer, must be 32-bit aligned
} MMCSD_DmaConfigData;
/*----- Function prototypes -----*/
STATUS MMCSD_setConfig(MMCSD_ConfigData * mmcsdConfig);
STATUS MMCSD_setIntMode(MMCSD_IntMode * mmcsdInt);
STATUS MMCSD_setDataSize(Uint16 numBlks, Uint16 blockSize);
STATUS MMCSD_setClock(BOOL enable, Uint16 clockRate);
STATUS MMCSD_getStatus(Uint16 * status0, Uint16* status1);
STATUS MMCSD_getResponse(MMCSD_ResponseData * mmcsdResponse);
STATUS MMCSD_setDmaConfig(MMCSD_DmaConfigData * dmaConfig);
STATUS MMCSD_updateDmaAddress(Uint32 sdramAddress);
STATUS MMCSD_dmaStart();
STATUS MMCSD_dmaStop();
STATUS MMCSD_dmaWait();
Uint32 MMCSD_getDmaCount();
//To be implemented later
STATUS MMCSD_sendCmd(Uint16 command, Uint32 argument);
#endif /* _MMCSD270_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -