nand_read nand 读数据函数

void nand_read(unsigned char * buf, unsigned long start_addr, int size)   //**********note : the type of buf and read_data same***********//
{
 int i, j;

 nand_select_chip();

 for(i = start_addr; i < (start_addr + size); i++)
 {
  // send out cmd 0
  write_cmd(0x00);

  // write address
  write_addr(i);

  write_cmd(0x30);

  wait_idle();

  for(j = 0;  j < NAND_SECTOR_SIZE_LP; j++, i++)
  {
   *buf = read_data8();
   buf++;
  }
 }

 wait_idle();

 nand_deselect_chip(); 
}

 

注意:read_data 函数读取的字节数要和参数 buf 的类型相匹配

 


版权声明:本文为xiarong715原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。