|
引用 4 楼 zzqccc 的回复:
谢谢两位,我明白了。
再看下面的转换又迷糊了
#define AMD_READ_USHORT(addr)? ? ? ? ? *((volatile unsigned short *)(addr))
BOOL AM29LV800_Init(UINT32 dwAddr)
{
? ? UINT16 MfgCode = 0;
? ? UINT16 DevCode = 0;
? ? BOOLEAN bResult = FALSE;
? ? OALMSG(OAL_FUNC, (TEXT("+AM29LV800_Init.\r\n")));
? ? AMD_WRITE_CMD(AMD_CMD_RESET);
? ? AMD_UNLOCK_CHIP();
? ? AMD_WRITE_CMD(AMD_CMD_AUTOSEL);
? ? // Read the manufacturer and device codes.
? ? //
? ? MfgCode = AMD_READ_USHORT(dwAddr);
? ? DevCode = AMD_READ_USHORT(dwAddr + 2);
? ? // Is this the expected AMD flash part?
? ? //
? ? if (MfgCode != AMD_MFG_CODE || DevCode != AMD_DEV_CODE)
? ? {
? ? ? ? OALMSG(OAL_ERROR, (TEXT("ERROR: AM29LV800_Init: Bad manufacturer or device code: Mfg=0x%x, Dev=0x%x.\r\n"), MfgCode, DevCode));
? ? ? ? goto CleanUp;
? ? }
将AMD_FLASH_START 的值unsigned int 0xB2000000 转成unsigned short 赋值给MfgCode,为什么要这样转一下?有何意义?
MfgCode打印出来的值是0x11,DevCode的值是0xea00,这两个值怎么转出来的?
这个并不是转成unsigned short, 而是读那个地址的值。 |
|