📄 sd_datatype.h
字号:
#define bsMCI_DATA_ENABLE ( (unsigned long) 0)
#define bwMCI_DATA_ENABLE ( (unsigned long) 1)
#define bsMCI_DATA_DIRECTION ( (unsigned long) 1)
#define bwMCI_DATA_DIRECTION ( (unsigned long) 1)
#define bsMCI_DATA_MODE ( (unsigned long) 2)
#define bwMCI_DATA_MODE ( (unsigned long) 1)
#define bsMCI_DATA_DMA_ENABLE ( (unsigned long) 3)
#define bwMCI_DATA_DMA_ENABLE ( (unsigned long) 1)
#define bsMCI_DATA_BLOCKSIZE ( (unsigned long) 4)
#define bwMCI_DATA_BLOCKSIZE ( (unsigned long) 4)
#define MCI_DATA_WRITE ( (unsigned long) 0)
#define MCI_FIFO_UWORDS ( (unsigned long) 16)
#define MCI_FIFO_BYTES ( MCI_FIFO_UWORDS * 4 )
/*
* Description:
* Bit offsets and masks in CID register
*/
#define bsMCI_CID_MID 120 /*Manufacturer ID*/
#define bwMCI_CID_MID 8 /*Manufacturer ID*/
#define bsMCI_CID_OID 104 /*Application ID*/
#define bwMCI_CID_OID 16 /*Application ID*/
#define bsMCI_SD_CID_PNM_H 96 /*Product Name upper one ASCII chars*/
#define bwMCI_SD_CID_PNM_H 8 /*Product Name*/
#define bsMCI_SD_CID_PNM_L 64 /*Product Name lower four ASCII chars*/
#define bwMCI_SD_CID_PNM_L 32 /*Product Name*/
#define bsMCI_SD_CID_PRV 56 /*Product Revision*/
#define bwMCI_SD_CID_PRV 8 /*Product Revision*/
#define bsMCI_SD_CID_PSN 24 /*Product Serial Number*/
#define bwMCI_SD_CID_PSN 32 /*Product Serial Number*/
#define bsMCI_SD_CID_MDT 8 /*Manufacturing Date*/
#define bwMCI_SD_CID_MDT 12 /*Manufacturing Date*/
#define bsMCI_CID_PNM_H 88 /*Product Name upper two ASCII chars*/
#define bwMCI_CID_PNM_H 16 /*Product Name*/
#define bsMCI_CID_PNM_L 56 /*Product Name lower four ASCII chars*/
#define bwMCI_CID_PNM_L 32 /*Product Name*/
#define bsMCI_CID_PRV 48 /*Product Revision*/
#define bwMCI_CID_PRV 8 /*Product Revision*/
#define bsMCI_CID_PSN 16 /*Product Serial Number*/
#define bwMCI_CID_PSN 32 /*Product Serial Number*/
#define bsMCI_CID_MDT 8 /*Manufacturing Date*/
#define bwMCI_CID_MDT 8 /*Manufacturing Date*/
/*
* Description:
* Options for command sending
*/
#define MCI_CMDOPT_PENDING 1 /*waits for a CmdPend signal before sending*/
#define MCI_CMDOPT_IMMEDIATE 2 /*enables the command state engine*/
#define MCI_CMDOPT_IGNORE_CRC 4 /*ignores CRC errors as response will not be used*/
#define MCI_CMDOPT_IGNORE_TIMEOUT 8 /*ignores timeout errors*/
/*
* Description:
* Block size for all App Commands
*/
#define MCI_APPCMD_BLOCK_SIZE 512
/*
* Description:
* Generic constant for accessing all bits in a 32 bit word
*/
#define apBITS_ALL 0xFFFFFFFF
/*
* Description:
* Build a mask for the specified bits
*
* Implementation:
* __bws - a width/shift pair.
*
* Returns a mask with the bits to be addressed set and all others cleared
*
*/
#define apBIT_MASK(__bws) ((unsigned long)(((bw ## __bws)==32)?0xFFFFFFFF:((1U << (bw ## __bws)) - 1)) << (bs ## __bws))
/*
* Description:
* Clear the specified bits
*
* Implementation:
* __datum - the word of data to be modified
* __bws - a width/shift pair.
*
*/
#define apBIT_CLEAR(__datum, __bws) ((__datum) = ((__datum) & ~((unsigned long) apBIT_MASK(__bws))))
/*
* Description:
* Access the specified bits from a word of data as an integer value
*
* Implementation:
* __datum - the word of data to be accessed
* __bws - a width/shift pair.
*
* Returns The relevant bits masked from the data word shifted to bit zero
*
*/
#define apBIT_GET(__datum, __bws) ((unsigned long)(((__datum) & ((unsigned long) apBIT_MASK(__bws))) >> (bs ## __bws)))
/*
* Description:
* Place the specified value into the specified bits of a word of data
*
* Implementation:
* __datum - the word of data to be accessed
* __bws - a width/shift pair.
* __val - the data value to be shifted into the specified bits.
*
*/
#define apBIT_SET(__datum, __bws, __val) ((__datum) = ((unsigned long) (__datum) & (unsigned long)~(apBIT_MASK(__bws))) | \
((unsigned long) ((unsigned long)(__val) << (unsigned long)(bs ## __bws)) & (apBIT_MASK(__bws))))
/*
* Description:
* Bit offsets and masks in CID register
*/
#define bsMCI_CID_MID 120 /*Manufacturer ID*/
#define bwMCI_CID_MID 8 /*Manufacturer ID*/
#define bsMCI_CID_OID 104 /*Application ID*/
#define bwMCI_CID_OID 16 /*Application ID*/
#define bsMCI_SD_CID_PNM_H 96 /*Product Name upper one ASCII chars*/
#define bwMCI_SD_CID_PNM_H 8 /*Product Name*/
#define bsMCI_SD_CID_PNM_L 64 /*Product Name lower four ASCII chars*/
#define bwMCI_SD_CID_PNM_L 32 /*Product Name*/
#define bsMCI_SD_CID_PRV 56 /*Product Revision*/
#define bwMCI_SD_CID_PRV 8 /*Product Revision*/
#define bsMCI_SD_CID_PSN 24 /*Product Serial Number*/
#define bwMCI_SD_CID_PSN 32 /*Product Serial Number*/
#define bsMCI_SD_CID_MDT 8 /*Manufacturing Date*/
#define bwMCI_SD_CID_MDT 12 /*Manufacturing Date*/
#define bsMCI_CID_PNM_H 88 /*Product Name upper two ASCII chars*/
#define bwMCI_CID_PNM_H 16 /*Product Name*/
#define bsMCI_CID_PNM_L 56 /*Product Name lower four ASCII chars*/
#define bwMCI_CID_PNM_L 32 /*Product Name*/
#define bsMCI_CID_PRV 48 /*Product Revision*/
#define bwMCI_CID_PRV 8 /*Product Revision*/
#define bsMCI_CID_PSN 16 /*Product Serial Number*/
#define bwMCI_CID_PSN 32 /*Product Serial Number*/
#define bsMCI_CID_MDT 8 /*Manufacturing Date*/
#define bwMCI_CID_MDT 8 /*Manufacturing Date*/
/*
* Description:
* Bit offsets and masks in Card Specific Data
*/
#define bsMCI_CSD_STRUCTURE 126 /*CSD structure*/
#define bwMCI_CSD_STRUCTURE 2 /*CSD structure*/
#define bsMCI_CSD_SPEC_VERS 122 /*System specification version*/
#define bwMCI_CSD_SPEC_VERS 4 /*System specification version*/
#define bsMCI_CSD_TAACHI 115 /*asynch data access time*/
#define bwMCI_CSD_TAACHI 4 /*asynch data access time*/
#define bsMCI_CSD_TAACLO 112 /*asynch data access time*/
#define bwMCI_CSD_TAACLO 3 /*asynch data access time*/
#define bsMCI_CSD_NSAC 104 /*clocked data access time*/
#define bwMCI_CSD_NSAC 8 /*clocked data access time*/
#define bsMCI_CSD_MAXTRANHI 99 /*maximum transfer speed (high bits)*/
#define bwMCI_CSD_MAXTRANHI 4 /*maximum transfer speed (high bits)*/
#define bsMCI_CSD_MAXTRANLO 96 /*maximum transfer speed (low bits)*/
#define bwMCI_CSD_MAXTRANLO 3 /*maximum transfer speed (low bits)*/
#define bsMCI_CSD_CCC 84 /*card command classes supported*/
#define bwMCI_CSD_CCC 12 /*card command classes supported*/
#define bsMCI_CSD_RDBL 80 /*read block length*/
#define bwMCI_CSD_RDBL 4 /*read block length*/
#define bsMCI_CSD_RDBLP 79 /*read block partial allowed*/
#define bwMCI_CSD_RDBLP 1 /*read block partial allowed*/
#define bsMCI_CSD_WTBLMIS 78 /*read block misalign allowed*/
#define bwMCI_CSD_WTBLMIS 1 /*read block misalign allowed*/
#define bsMCI_CSD_RDBLMIS 77 /*read block misalign allowed*/
#define bwMCI_CSD_RDBLMIS 1 /*read block misalign allowed*/
#define bsMCI_CSD_DSR_IMP 76 /*DSR implimented*/
#define bwMCI_CSD_DSR_IMP 1 /*DSR implimented*/
#define bsMCI_CSD_CSIZE 62 /*card size*/
#define bwMCI_CSD_CSIZE 12 /*card size*/
#define bsMCI_CSD_CMULT 47 /*card multiplier*/
#define bwMCI_CSD_CMULT 3 /*card multiplier*/
#define bsMCI_CSD_ERASE_SECT 42 /*size of erase sector*/
#define bwMCI_CSD_ERASE_SECT 5 /*size of erase sector*/
#define bsMCI_CSD_ERASE_SECT_SD 39 /*size of erase sector for SD*/
#define bwMCI_CSD_ERASE_SECT_SD 7 /*size of erase sector for SD*/
#define bsMCI_CSD_ERASE_GRP 37 /*size of erase group*/
#define bwMCI_CSD_ERASE_GRP 5 /*size of erase group*/
#define bsMCI_CSD_WP_GRP_SIZE 32 /*write protect group size*/
#define bwMCI_CSD_WP_GRP_SIZE 5 /*write protect group size*/
#define bsMCI_CSD_WP_GRP_ENABLE 31 /*write protect group enable*/
#define bwMCI_CSD_WP_GRP_ENABLE 1 /*write protect group enable*/
#define bsMCI_CSD_ERASE_GRP_SIZE11 42 /* CSD v1.1 */
#define bwMCI_CSD_ERASE_GRP_SIZE11 5
#define bsMCI_CSD_ERASE_GRP_MULT11 37
#define bwMCI_CSD_ERASE_GRP_MULT11 5
#define bsMCI_CSD_WP_GRP_SIZE11 32
#define bwMCI_CSD_WP_GRP_SIZE11 5
#define bsMCI_CSD_R2W 26 /*Read/Write factor*/
#define bwMCI_CSD_R2W 3 /*Read/Write factor*/
#define bsMCI_CSD_WTBL 22 /*write block length*/
#define bwMCI_CSD_WTBL 4 /*write block length*/
#define bsMCI_CSD_WTBLP 21 /*write block partial allowed*/
#define bwMCI_CSD_WTBLP 1 /*write block partial allowed*/
#define bsMCI_CSD_FILE_FORMAT_GRP 15 /*file format group*/
#define bwMCI_CSD_FILE_FORMAT_GRP 1 /*file format group*/
#define bsMCI_CSD_COPY 14 /*copy flag (OTP)*/
#define bwMCI_CSD_COPY 1 /*copy flag (OTP)*/
#define bsMCI_CSD_PERM_WP 13 /*permanent write protect*/
#define bwMCI_CSD_PERM_WP 1 /*permanent write protect*/
#define bsMCI_CSD_TEMP_WP 12 /*temporary write protect*/
#define bwMCI_CSD_TEMP_WP 1 /*temporary write protect*/
#define bsMCI_CSD_FILE_FORMAT 10 /*file format*/
#define bwMCI_CSD_FILE_FORMAT 2 /*file format*/
#define bsMCI_CSD_CAN_ERASE 5 /*card supports erase commands (bit within MCI_CCC)*/
#define bwMCI_CSD_CAN_ERASE 1 /*card supports erase commands*/
#define bsMCI_CSD_ERASE_SINGLE_BLOCK_ENABLE 46
#define bwMCI_CSD_ERASE_SINGLE_BLOCK_ENABLE 1
#define bsMCI_CSD_C_SIZE_MULT 47
#define bwMCI_CSD_C_SIZE_MULT 2
#define bsMCI_CSD_VDD_W_CURR_MAX 50
#define bwMCI_CSD_VDD_W_CURR_MAX 3
#define bsMCI_CSD_VDD_W_CURR_MIN 53
#define bwMCI_CSD_VDD_W_CURR_MIN 3
#define bsMCI_CSD_VDD_R_CURR_MAX 56
#define bwMCI_CSD_VDD_R_CURR_MAX 3
#define bsMCI_CSD_VDD_R_CURR_MIN 59
#define bwMCI_CSD_VDD_R_CURR_MIN 3
#define bsMCI_CSD_CRC 1
#define bwMCI_CSD_CRC 7
/*
* Description:
* Decoded fields for card-specific data
*/
typedef struct apMCI_xDecodedCSD
{
unsigned char csd_structure; /* version number of CSD structure (should always be 1) */
unsigned long data_read_access_time_1_tns /* first part of read access time, in tenths-of-nanoseconds (e.g. 500 means 50ns) */;
unsigned long data_read_access_time_2_in_clk_cycles; /* second part of read access time, in card bus clock cycles */
unsigned long max_data_transfer_rate_khz; /* maximum frequency of card's data line(s) in kHz */
unsigned long card_command_classes; /* bit pattern of the command classes that this card supports */
unsigned long max_read_data_block_length; /* in bytes */
BOOL partial_blocks_for_read_allowed;
BOOL write_block_misalignment;
BOOL read_block_misalignment;
BOOL dsr_implemented;
unsigned long device_size; /* not very meaningful on its own... */
unsigned char max_read_current_min; /* encoded as per Physical Layer Spec */
unsigned char max_read_current_max; /* encoded as per Physical Layer Spec */
unsigned char max_write_current_min; /* encoded as per Physical Layer Spec */
unsigned char max_write_current_max; /* encoded as per Physical Layer Spec */
unsigned long device_size_multiplier; /* not very meaningful on its own... */
BOOL erase_single_block_enable;
unsigned long erase_sector_size; /* in blocks (of max_write_data_block_length) */
unsigned long write_protect_group_size; /* in erase sectors */
BOOL write_protect_group_enable;
unsigned long write_speed_factor; /* how many times slower is write, compared to read? */
unsigned long max_write_data_block_length; /* in bytes */
BOOL partial_blocks_for_write_allowed;
unsigned char file_format_group; /* encoded as per Physical Layer Spec */
BOOL copy_flag;
BOOL permanent_write_protection;
BOOL temporary_write_protection;
unsigned char file_format; /* encoded as per Physical Layer Spec */
unsigned char crc; /* not checked */
/* Calculated field */
unsigned long CardSize; /*card size in bytes*/
} apMCI_sDecodedCSD;
/*
* Description:
* Decoded fields for card identification data
*/
typedef struct apMCI_xDecodedCID
{
unsigned long MID; /*Manufacturer ID*/
unsigned long OID; /*Application ID*/
unsigned char PNM[7]; /*Product Name*/
unsigned long PRV; /*Product Revision*/
unsigned long PSN; /*Product serial number*/
unsigned long MDT; /*Product manufacturing date*/
} apMCI_sDecodedCID;
#define bsMCI_CLOCK_CLKDIV ( (unsigned long) 0)
#define bwMCI_CLOCK_CLKDIV ( (unsigned long) 8)
#define bsMCI_CLOCK_MODE ( (unsigned long) 8)
#define bwMCI_CLOCK_MODE ( (unsigned long) 2)
#define bsMCI_CLOCK_PWRSAVE ( (unsigned long) 9)
#define bwMCI_CLOCK_PWRSAVE ( (unsigned long) 1)
#define bsMCI_CLOCK_BYPASS ( (unsigned long) 10)
#define bwMCI_CLOCK_BYPASS ( (unsigned long) 1)
#define bsMCI_CLOCK_WIDE ( (unsigned long) 11)
#define bwMCI_CLOCK_WIDE ( (unsigned long) 1)
// In test mode, we get these data
#define MCI_CLOCK_DIV_FASTEST 7 /*fastest speed allowed (ref clock /7)*/
#define MCI_CLOCK_DIV_SLOWEST 511 /*slowest speed allowed (ref clock /511)*/
#pragma pack()
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -