Re: The problem of Reading unique Device ID of MMC/SD card on PXA270
- From: "alexu" <xalexu@xxxxxxxxx>
- Date: Fri, 26 Jan 2007 09:55:33 +0800
nobody can help me? Please give me some advices!Thanks!
"alexu" <xalexu@xxxxxxxxx> дÈëÓʼþ
news:OOhoUO3PHHA.4172@xxxxxxxxxxxxxxxxxxxxxxx
Hi!card
the os's version is WindowsCE5.0.
I use these two functions to map the physical address to the virtual
address in
order to access physical registers in User Mode:
BOOL VirtualCopy( LPVOID lpvDest, LPVOID lpvSrc, DWORD cbSize, DWORD
fdwProtect );
LPVOID VirtualAlloc( LPVOID lpAddress, DWORD dwSize, DWORD
flAllocationType, DWORD flProtect );
Then i got the registers' physical address about controling MMC\SD
successfully;After that, i send CMD2(after this ,the
SD/MMC card will response with a 128 BITS serial number)via MMC_CMD
register.then i was waiting for the END_CMD_RES
interupt ,but the this interupt's bit was always not set,so i can't get
serial number of SD/MMC;something
i think that the reason maybe that i didn't pay attention to
about accessing physical address in USERMMC_CMDAT[10]
MODE in WindowsCE; who can help me! Thanks!
these my codes:
int PXA270MMCSerialNumberRead( DWORD * buffer )
{
volatile PxaMMCReg * pMMCReg;
pMMCReg = ( volatile PxaMMCReg * )MmMapIoSpace(
(void*)MMC_PHY_BASE, sizeof(PxaMMCReg), FALSE );//this run successfully
if ( pMMCReg == NULL )
{
return FALSE;
}
//send STOP-TRANSMISSION to stop current data transfermation
unsigned int cmdatstop = pMMCReg->rMMC_CMDAT;
cmdatstop |= CMDAT_RESP_R1;
cmdatstop |= (1<<10);
pMMCReg->rMMC_CMDAT = cmdatstop;//there is a bit in
seems likeMMC_RES
//that control STOPTRANS
pMMCReg->rMMC_CMD = 0x4c;//cmd12
pMMCReg->rMMC_CMDAT = cmdatstop;
unsigned int cmdat = pMMCReg->rMMC_CMDAT;
//set the way of responsing
cmdat |= CMDAT_RESP_R2;
//we set command register
pMMCReg->rMMC_CMD = 0x42;//cmd2
//pMMCReg->rMMC_ARGH = 0;
//pMMCReg->rMMC_ARGL = 0;
pMMCReg->rMMC_CMDAT = cmdat;
//enable the END_CMD_RES interupts
//pMMCReg->rMMC_I_MASK &= ~END_CMD_RES;
unsigned int imask = pMMCReg->rMMC_I_MASK;
imask &= ~END_CMD_RES;
imask &= (0<<13)|(0xfff);
pMMCReg->rMMC_I_MASK = imask;
while(!( pMMCReg->rMMC_I_REG & ( 1<<2 ) ) )//weitting for
interupts occured, but this always didn't occured
//read the response from MMC disk
int i;
u32 resp[4];
u32 v = pMMCReg->rMMC_RES & 0xffff;
for (i = 0; i < 4; i++)
{
u32 w1 = pMMCReg->rMMC_RES & 0xffff;
u32 w2 = pMMCReg->rMMC_RES & 0xffff;
resp[i] = v << 24 | w1 << 8 | w2 >> 8;
v = w2;
}
pMMCReg->rMMC_I_MASK |= END_CMD_RES;
memcpy( buffer, resp, sizeof(u32)*4 );
VirtualFree((void *)pMMCReg, 0, MEM_RELEASE);
pMMCReg = NULL;
return TRUE;
}
.
- References:
- Prev by Date: Re: VS2005 & SDK
- Next by Date: Re: How to turn on/off phone radio programmatically
- Previous by thread: The problem of Reading unique Device ID of MMC/SD card on PXA270
- Next by thread: CE5 MFC, How can I prevent an application from re-entering
- Index(es):
Relevant Pages
|
Loading