Re: I'm qurious about some code in CSDIOControllerBase::GetCommandResponse member function



Yes, it's assuming, by assigning the bytes in the respBuff in the order, for
offsets +1 to +4 that it is, the endian arrangement of bytes. However, no,
you don't have to change the other line of code. Presumably SDIRSP1 is a
32-bit integer, right? If so, you don't have to worry about how memory is
arranged. The compiler takes care of that. SDIRSP1 >> 24 is *ALWAYS* the
MSB of the 32-bit value, regardless of the endian settings.

Paul T.

<shjkun@xxxxxxxxx> wrote in message
news:838d7ffa-a20c-4401-b21d-b15354adecf6@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
How are u?
As I mentioned in the titile box, I'm qurious about some code in
CSDIOControllerBase::GetCommandResponse member function.

SD_API_STATUS CSDIOControllerBase::GetCommandResponse(PSD_BUS_REQUEST
pRequest)
{
...
DEBUGMSG (SDHC_RESPONSE_ZONE,(TEXT("GetCommandResponse
started")));
PUCHAR respBuff; // response buffer
DWORD dwWaitCount = 0;

//----- 1. Wait for the response information to get arrive at the
controller -----
while(!(vm_pSDIReg->SDICSTA & RESPONSE_RECEIVED))
{
...
}

respBuff = pRequest->CommandResponse.ResponseBuffer;
switch(pRequest->CommandResponse.ResponseType)
{
....
case ResponseR5:
case ResponseR6:
//--- SHORT RESPONSE (48 bits total)---
// Format: { START_BIT(1) | TRANSMISSION_BIT(1) |
COMMAND_INDEX(6) | RCA(16) |
// CARD_STATUS(16) | CRC7(7) | END_BIT(1) }
//
*(respBuff ) = (BYTE)(START_BIT | TRANSMISSION_BIT |
pRequest->CommandCode);
*(respBuff + 1) = (BYTE)(vm_pSDIReg->SDIRSP0 );
*(respBuff + 2) = (BYTE)(vm_pSDIReg->SDIRSP0 >> 8 );
*(respBuff + 3) = (BYTE)(vm_pSDIReg->SDIRSP0 >> 16);
*(respBuff + 4) = (BYTE)(vm_pSDIReg->SDIRSP0 >> 24);
*(respBuff + 5) = (BYTE)(vm_pSDIReg->SDIRSP1 >> 24); <--
....
}

As I know,
*(respBuff + 1) = (BYTE)(vm_pSDIReg->SDIRSP0 );
*(respBuff + 2) = (BYTE)(vm_pSDIReg->SDIRSP0 >> 8 );
*(respBuff + 3) = (BYTE)(vm_pSDIReg->SDIRSP0 >> 16);
*(respBuff + 4) = (BYTE)(vm_pSDIReg->SDIRSP0 >> 24);

the code, as we can see above this line, is coded to adapt little
endian.
but
*(respBuff + 5) = (BYTE)(vm_pSDIReg->SDIRSP1 >> 24);

I think, if we adapt this code to little endian we must code like
below

*(respBuff + 5) = (BYTE)(vm_pSDIReg->SDIRSP1);
but it dosn't do like that.

why ??


.