小弟在做一个stm32读nand flash的试验。。
#define Bank2_NAND_ADDR ((uint32_t)0x70000000)
#define Bank_NAND_ADDR Bank2_NAND_ADDR
#define CMD_AREA (uint32_t)(1<<16)
#define ADDR_AREA (uint32_t)(1<<17)
#define NAND_CMD_AREA *(__IO uint8_t *)(Bank_NAND_ADDR | CMD_AREA)
#define NAND_ADDR_AREA *(__IO uint8_t *)(Bank_NAND_ADDR | ADDR_AREA)
uint32_t NAND_ReadID(void)
{
uint32_t data = 0;
NAND_CMD_AREA = 0x90;
NAND_ADDR_AREA = 0x00;
data = *(__IO uint32_t *)(Bank_NAND_ADDR | DATA_AREA);
data = ((data << 24) & 0xFF000000) |
((data << 8 ) & 0x00FF0000) |
((data >> 8 ) & 0x0000FF00) |
((data >> 24) & 0x000000FF) ;
return data;
}
这是一个读nand flash id的函数。我真心看不懂。NAND_CMD_AREA和NAND_ADDR_AREA根据宏定义不是一个固定值吗?这个在函数里还给它们赋值啊,NAND_CMD_AREA = 0x90;NAND_ADDR_AREA = 0x00;还有data = *(__IO uint32_t *)(Bank_NAND_ADDR | DATA_AREA);这个是什么意思啊,。求解,大虾们 |