求565/569評估板EMMC存儲器擦除的例程,郵箱個人信息保護,已隱藏
謝謝
求565/569評估板EMMC存儲器擦除的例程,郵箱個人信息保護,已隱藏
謝謝
CH569EVT例程中提供了EMMC命令執(zhí)行函數(shù):
#define?EMMCSendCmd(a,?b)?{R32_EMMC_ARGUMENT?=?a;?R16_EMMC_CMD_SET?=?b;}
根據(jù)標準
(圖片截取自《嵌入式多媒體設備(e-MMC)電氣標準 4.51》)
R32_EMMC_ARGUMENT寄存器傳入參數(shù),R16_EMMC_CMD_SET寄存器傳入命令號以及命令類型。
具體可以通過學習塊寫、塊讀、讀EXCSD時的調用方式,對照協(xié)議修改一下即可。
EMMC通常不需要擦就可以直接寫入。
例子1:CMD8
例程代碼:
UINT8?EMMCCardReadEXCSD(?PSD_PARAMETER?pEMMCPara,?PUINT8?pRdatbuf?) { ????UINT32?cmd_arg_val; ????UINT16?cmd_set_val; ????R32_EMMC_DMA_BEG1?=?(UINT32)pRdatbuf; ????R32_EMMC_TRAN_MODE?=?0; ????R32_EMMC_BLOCK_CFG?=?512<<16?|?1; ????cmd_arg_val?=?0; ????cmd_set_val?=?RB_EMMC_CKIDX?| ??????????????????RB_EMMC_CKCRC?| ??????????????????RESP_TYPE_48??| ??????????????????EMMC_CMD8; ????EMMCSendCmd(cmd_arg_val,?cmd_set_val); ????while(1) ????{ ????????if(R16_EMMC_INT_FG?&?RB_EMMC_IF_TRANDONE)???break; ????????if(?pEMMCPara->EMMCOpErr?)??????return?CMD_FAILED; ????} ????R16_EMMC_INT_FG?=?0xffff; ????return??OP_SUCCESS; }
其中:
1、應答類型,SPEC指示為R1,例程參數(shù)為RESP_TYPE_48
2、參數(shù),SPEC指示為填充位,即沒什么用,所以例程代碼賦值0
例子2:CMD9
例程代碼:
UINT8?EMMCReadCSD(?PSD_PARAMETER?pEMMCPara?) { ????UINT32?cmd_arg_val; ????UINT16?cmd_set_val; ????UINT8??sta; ????UINT32?disk_block_num?=?0; ????cmd_arg_val?=?pEMMCPara->EMMC_RCA<<16; ????cmd_set_val?=?0?| ??????????????????0?| ??????????????????RESP_TYPE_136?| ??????????????????EMMC_CMD9; ????EMMCSendCmd(cmd_arg_val,?cmd_set_val); ????while(1) ????{ ????????sta?=?CheckCMDComp(?pEMMCPara?); ????????if(?sta?!=?CMD_NULL?)?break; ????} ????if(sta?==?CMD_SUCCESS) ????{ ????????pEMMCPara->EMMC_CSD[0]?=?R32_EMMC_RESPONSE0; ????????pEMMCPara->EMMC_CSD[1]?=?R32_EMMC_RESPONSE1; ????????pEMMCPara->EMMC_CSD[2]?=?R32_EMMC_RESPONSE2; ????????pEMMCPara->EMMC_CSD[3]?=?R32_EMMC_RESPONSE3; ????????disk_block_num?=?(((pEMMCPara->EMMC_CSD[2]&0x3ff)<<2)?|?((pEMMCPara->EMMC_CSD[1])>>30)); ????????if(disk_block_num?==?0xFFF) ????????{ ????????????pEMMCPara->EMMCSecNum?=?0xFFF; ????????} ????????else ????????{ ????????????pEMMCPara->EMMCType?=?EMMCIO_CAPACITY_SD_CARD_V2_0; ????????????/*?memory?capacity?=?BLOCKNR*BLOCK_LEN?=?(C_SIZE+1)<<(C_SIZE_MULT+2)<<(READ_BL_LEN)?*/ ????????????disk_block_num?=?(?(((pEMMCPara->EMMC_CSD[2]&0x3ff)<<2)?|?(pEMMCPara->EMMC_CSD[1]>>30))?+?1?); ????????????disk_block_num?=?(?(disk_block_num)?<<?(((pEMMCPara->EMMC_CSD[1]>>15)&0x07)?+?2)); ????????} ????} ????pEMMCPara->EMMCSecSize?=?1<<((pEMMCPara->EMMC_CSD[2]>>16)&0x000f); ????return?sta; }
其中:
1、應答類型,SPEC指示為R2,例程參數(shù)為RESP_TYPE_136
2、參數(shù),SPEC指示為[31:16] RCA
[15:0] 填充位,例程代碼賦值pEMMCPara->EMMC_RCA<<16
調用方式類似,根據(jù)SPEC指示,將參數(shù)寫入到兩個寄存器中。