write_command( )——写命令函数 write_address( )——写地址函数 write_data( )——写数据函数 read_data( )——读数据函数 void flash_store(uint32 row_add, uint8 *buffer ) {uint16 i; uint32 statue,address; //变量定义 IO0DIR = 0x00ff0000; //设定IO方向 if((row_add== 0) ((row_add%32)==0)) {address = row_add<<9; address &= 0x00fffe00; erase_flash(address);} //擦除Flash write_command(0x80); //写命令80H address = row_add<<9; address &= 0x00fffe00; write_address(address); //写地址 statue = IO0PIN; //获取状态 while((statue&fr_b)==0) {statue = IO0PIN;} //忙,等待 for(i=0;i<528;i++) //写528字节 {write_data(*(buffer+i));} //写入数据 write_command(0x10); //写命令10H statue = IO0PIN; //获取状态 while((statue&fr_b)==0) {statue = IO0PIN;} //忙,等待 write_command(0x70); //写命令70H statue = read_data(); //获取状态 if(statue&0x01) {IO0SET = errorled;} //操作失败 }LPC2114串口通信实现 |
欢迎光临 DIY编程器网 (http://diybcq.com/) | Powered by Discuz! X3.2 |