引用 12 楼 wang19847277 的回复:
这个问题是不是要先考虑是否能支持小容量的SD呢?之后在研究大容量的SDHC
是不是按照楼主上面那样修改呢?试了没有效果啊
SD_API_STATUS CSDIOControllerBase::SendCommand(UINT16 Cmd, UINT32 Arg, UINT16 respType, BOOL bDataTransfer)
{
unsigned int uiNewCmdRegVal = 0;
DWORD dwWaitCount = 0;
PUCHAR respBuff; // response buffer
PSD_BUS_REQUEST pRequest;
DEBUGMSG (SDHC_SEND_ZONE,(TEXT("SendCommand (0x%08x, 0x%04x, 0x%08x, 0x%04x, 0x%x) starts\r\n"),
......
case ResponseR1: // Short response required
case ResponseR1b:
case ResponseR3:
case ResponseR4:
case ResponseR5:
case ResponseR6:
DEBUGMSG (SDHC_SEND_ZONE,(TEXT("sendSDICommand short response required\r\n")));
// vm_pSDIReg->SDICCON = uiNewCmdRegVal | WAIT_FOR_RESPONSE | START_COMMAND | COMMAND_START_BIT | (Cmd & MAX_CMD_VALUE);
vm_pSDIReg->rSDICMDCON = WAIT_FOR_RESPONSE | START_COMMAND | COMMAND_START_BIT | (Cmd & MAX_CMD_VALUE);
break;
case ResponseR7: // add by wogo at 2009.05.06添加的地方
//--- SHORT RESPONSE (48 bits total)---
// Format: { START_BIT(1) | TRANSMISSION_BIT(1) | COMMAND_INDEX(6) | CARD_STATUS(32) | CRC7(7) | END_BIT(1) }
// NOTE: START_BIT and TRANSMISSION_BIT = 0, END_BIT = 1
//
*(respBuff ) = (BYTE)(START_BIT | TRANSMISSION_BIT | pRequest->CommandCode);
*(respBuff + 1) = (BYTE)(vm_pSDIReg->rSDIRSP0 );
*(respBuff + 2) = (BYTE)(vm_pSDIReg->rSDIRSP0 >> 8 );
*(respBuff + 3) = (BYTE)(vm_pSDIReg->rSDIRSP0 >> 16);
*(respBuff + 4) = (BYTE)(vm_pSDIReg->rSDIRSP0 >> 24);
*(respBuff + 5) = (BYTE)(END_RESERVED | END_BIT);
break;
case ResponseR2: // Long response required
DEBUGMSG (SDHC_SEND_ZONE,(TEXT("sendSDICommand long response
......
}
.......
SD_API_STATUS CSDIOControllerBase::GetCommandResponse(PSD_BUS_REQUEST pRequest)
{
DEBUGMSG (SDHC_SEND_ZONE,(TEXT("GetCommandResponse started\r\n")));
PUCHAR respBuff; // response buffer
DWORD dwWaitCount = 0;
.......
switch(pRequest->CommandResponse.ResponseType)
{
case NoResponse:
break;
case ResponseR1:
case ResponseR1b:
//--- SHORT RESPONSE (48 bits total)---
// Format: { START_BIT(1) | TRANSMISSION_BIT(1) | COMMAND_INDEX(6) | CARD_STATUS(32) | CRC7(7) | END_BIT(1) }
// NOTE: START_BIT and TRANSMISSION_BIT = 0, END_BIT = 1
//
*(respBuff ) = (BYTE)(START_BIT | TRANSMISSION_BIT | pRequest->CommandCode);
*(respBuff + 1) = (BYTE)(vm_pSDIReg->rSDIRSP0 );
*(respBuff + 2) = (BYTE)(vm_pSDIReg->rSDIRSP0 >> 8 );
*(respBuff + 3) = (BYTE)(vm_pSDIReg->rSDIRSP0 >> 16);
*(respBuff + 4) = (BYTE)(vm_pSDIReg->rSDIRSP0 >> 24);
*(respBuff + 5) = (BYTE)(END_RESERVED | END_BIT);
break;
case ResponseR7: //------------------------添加的地方
//--- SHORT RESPONSE (48 bits total)---
// Format: { START_BIT(1) | TRANSMISSION_BIT(1) | COMMAND_INDEX(6) | CARD_STATUS(32) | CRC7(7) | END_BIT(1) }
// NOTE: START_BIT and TRANSMISSION_BIT = 0, END_BIT = 1
//
*(respBuff ) = (BYTE)(START_BIT | TRANSMISSION_BIT | pRequest->CommandCode);
*(respBuff + 1) = (BYTE)(vm_pSDIReg->rSDIRSP0 );
*(respBuff + 2) = (BYTE)(vm_pSDIReg->rSDIRSP0 >> 8 );
*(respBuff + 3) = (BYTE)(vm_pSDIReg->rSDIRSP0 >> 16);
*(respBuff + 4) = (BYTE)(vm_pSDIReg->rSDIRSP0 >> 24);
*(respBuff + 5) = (BYTE)(END_RESERVED | END_BIT);
break;
case ResponseR3:
case ResponseR4:
//--- SHORT RESPONSE (48 bits total)---
// Format: { START_BIT(1) | TRANSMISSION_BIT(1) | RESERVED(6) | CARD_STATUS(32) | RESERVED(7) | END_BIT(1) }
//
*(respBuff ) = (BYTE)(START_BIT | TRANSMISSION_BIT | START_RESERVED);
*(respBuff + 1) = (BYTE)(vm_pSDIReg->rSDIRSP0 );
*(respBuff + 2) = (BYTE)(vm_pSDIReg->rSDIRSP0 >> 8 );
*(respBuff + 3) = (BYTE)(vm_pSDIReg->rSDIRSP0 >> 16);
*(respBuff + 4) = (BYTE)(vm_pSDIReg->rSDIRSP0 >> 24);
*(respBuff + 5) = (BYTE)(END_RESERVED | END_BIT);
break;
case ResponseR5:
case ResponseR6:
.......
}
两个函数里是这样添加的,请大家仔细看一下,有没有添加错了