有高手在吗?我从网上下载一个c语言程序,控制nandflash的 没有main() 主函数 这是为什么啊? 程序里面也没有定义什么的,这段是什么一思啊 谢谢啊!小弟急求啊!
程序如下: unsigned char ReadByte(unsigned int blockadd,unsigned char pageadd); unsigned char ReadSpare(unsigned int blockadd,unsigned char pageadd); unsigned char ReadStatus(void); unsigned int ReadID(void); void BadBlockScan(void); void CopyBack(unsigned int blockaddh_s,blockaddh_e); void EraseBlock(unsigned int blockadd); void NfAddre(unsigned int blockadd,unsigned char pageadd); void NfCommand(unsigned char Com); void ReadPage(unsigned int blockadd,unsigned char pageadd); void ReadPageS(unsigned int blockadd,unsigned char select,pageadd); void WirteByte(unsigned int blockadd,unsigned char pageadd,unsigned char buf); void WirtePage(unsigned int blockadd,unsigned char pageadd); void WirtePageF(unsigned int blockadd); void WirteSpare(unsigned int blockadd,unsigned char pageadd,unsigned char buf);
/*============================================================================= //参 数: unsigned char Com //函数功能: 向K9F5608操作命令 =============================================================================*/ void NfCommand(unsigned char Com) { NF_CLE=1; NF_WE=0; P1=Com; _nop_(); NF_WE=1; NF_CLE=0; P1=0xff; } /*============================================================================= //参 数: unsigned int bolckadd 2nd 3th的地址 (Row地址) unsigned char pageadd 1st的地址 (Column地址) //函数功能: 向K9F5608送地址 =============================================================================*/ void NfAddre(unsigned int blockadd,unsigned char pageadd) { NF_ALE=1; NF_WE=0; P1=pageadd; _nop_(); NF_WE=1;
//送地址第一个字节 NF_WE=0; P1=blockadd&0xff; _nop_(); NF_WE=1;
//送地址第二个字节 NF_WE=0; P1=blockadd/256; _nop_(); NF_WE=1;
//送地址第三个字节 NF_ALE=0; P1=0xff; } /*============================================================================= //参 数: unsigned int blockaddh 2nd 3th的地址 (Row地址)
//函数功能: 页读 PAGE READ OPERATION 可连续读512个字节 =============================================================================*/
void ReadPageF(unsigned int blockadd) { unsigned int i; NF_RE=1;NF_CE=0;NF_CLE=0;NF_ALE=0;NF_WE=1;NF_WP=1; NfCommand(0); //送
读命令 NfAddre(blockadd,0); //送开始字节 NF_RB=1;while(!NF_RB); //Data Transfer from Cell to Register
max 10us i=0; P1=0xff; do { NF_RE=0; DataArray=P1; NF_RE=1; i++; } while(i<512); //第1
页数据传送数据完成 NF_CE=1; } /*============================================================================= //参 数: unsigned int blockaddh 2nd 3th的地址 (Row地址) unsigned char pageadd 1st的地址 (Column地址) //函数功能: 页读 PAGE READ OPERATION 可连续写256个字节 =============================================================================*/
void ReadPage(unsigned int blockadd,unsigned char pageadd) { unsigned char i; NF_RE=1;NF_CE=0;NF_CLE=0;NF_ALE=0;NF_WE=1;NF_WP=1; NfCommand(0); //送
读命令 NfAddre(blockadd,pageadd); //送开始字节地址 NF_RB=1;while(!NF_RB); //Data Transfer from Cell to Register
max 10us i=0; P1=0xff; do { NF_RE=0; DataArray=P1; NF_RE=1; i++; } while(i);
//页数据传送数据完成 NF_CE=1; } /*============================================================================= //参 数: unsigned int blockaddh 2nd 3th的地址 (Row地址) unsigned char pageadd 1st的地址 (Column地址) //函数功能: 页读 PAGE READ OPERATION 可连续写512个字节 //___没有调试 =============================================================================*/
void ReadPageS(unsigned int blockadd,unsigned char pageadd,select) { NF_RE=1;NF_CE=0;NF_CLE=0;NF_ALE=0;NF_WE=1;NF_WP=1; NfCommand(select); //送读命令 NfAddre(blockadd,pageadd); //送开始字节 NF_RB=1;while(!NF_RB); //Data Transfer from Cell to Register
max 10us DataPtr+=pageadd; do { NF_RE=0; pageadd++; *DataPtr=P1; DataPtr++; NF_RE=1; } while(pageadd<256);
//页数据传送数据完成 NF_CE=1; } /*============================================================================= //参 数: unsigned int blockaddh 2nd 3th的地址 (Row地址) unsigned char pageadd 1st的地址 (Column地址) //函数功能: BYTE READ OPERATION 只读取一个字节 =============================================================================*/
unsigned char ReadByte(unsigned int blockadd,unsigned char pageadd) { unsigned char i; NF_RE=1;NF_CE=0;NF_CLE=0;NF_ALE=0;NF_WE=1;NF_WP=1; NfCommand(0); //送
读命令 NfAddre(blockadd,pageadd); //送开始字节 NF_RB=1;while(!NF_RB); //Data Transfer from Cell to Register
max 10us NF_RE=0; P1=0xff; i=P1; NF_RE=1; NF_CE=1; return(i); } /*============================================================================= //参 数: unsigned int blockaddh 2nd 3th的地址 (Row地址) unsigned char pageadd 1st的地址 (Column地址) //函数功能: 保留字读 Command input sequence for programming ’C’ area 只读一个字节 =============================================================================*/
unsigned char ReadSpare(unsigned int blockadd,unsigned char pageadd) { unsigned char j; NF_RE=1;NF_CE=0;NF_CLE=0;NF_ALE=0;NF_WE=1;NF_WP=1; NfCommand(0x50);
//读C页数据512-527 NfAddre(blockadd,pageadd); //送开始字节 NF_RB=1;while(!NF_RB); //Data Transfer from Cell to Register
max 10us NF_RE=0; P1=0xff; j=P1; NF_RE=1; NF_CE=1; return(j); } |