小弟最近在学习用STM32读写NAND Flash,但是开发板带的例程怎么也看不懂,请高手指点一二。小弟的问题是:红色字体的地址数据到底怎么跟flash的地址对应起来?
感觉无法理解它为什么这么写。还一个:蓝色字体为什么参数是零呢?谢谢了!
/*******************************************************************************
* Function Name : Nand_Page_Read
* Description : NAND页读(一次2K)
* Input : - buffer:
* - PageAddr:
* - BlockAddr:
* Output : None
* Return : None
* Attention : None
*******************************************************************************/
uint8_t Nand_Page_Read(uint8_t *buffer,uint8_t PageAddr,uint16_t BlockAddr)
{
uint8_t AddrLow;
uint8_t AddrHigh;
uint16_t Addr;
Addr = BlockAddr + ( PageAddr << 10 );
AddrLow = (uint8_t)( Addr & 0xff );
AddrHigh = (uint8_t)( ( PageAddr >> 8 ) & 0xff );
Nand_Command_Send(0x00);
Nand_Address_Send(0);
Nand_Address_Send(0);
Nand_Address_Send(AddrHigh);
Nand_Address_Send(AddrLow);
Nand_Command_Send(0x30);
while(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_5) == 0); /* 等待写完成 为低表示忙 */
for( Addr=0; Addr<2048; Addr++ )
{
buffer[Addr] = Nand_RDad_Data();
}
return 0;
} |