📄 rom_drv.c
字号:
/***************************************************************************** FileName: rom_drv.c* Revision: 2006/6/6* Author: Wang Lihui****************************************************************************** DESCRIPTION: rom operation interface** COPYRIGHT: (C) HEBEI FAR-EAST HARRIS COMMUNICATIONS COMPANY LTD.* HISTORY: 06/06/06: Initial verison by Wang Lihui 08/07/25 Second verison by Du Biao**/#include <stdio.h>#include <stdlib.h>#include <fcntl.h>//#include <unistd.h>#include "../inc/version.h"#include "../inc/gendef.h"#include "../inc/rom_drv.h"#include "../inc/intel28f160.h"#include "../inc/msgpkt.h"#include "../inc/channel.h"int ROM_Init(U8 flash_type){// return open("/dev/nandflashdrv",O_RDWR); if(flash_type == NAND_FLASH) { return open("/dev/nandflashdrv", O_RDWR); } else if(flash_type == INTEL28F160C3B) { return 0; } else { return -1; }}int ROM_EraseBlock(U8 flash_type, int dev, U16 index){ if(flash_type == NAND_FLASH) { return (ioctl(dev, CMD_NF_ERASE_BLOCK, index)); } else if(flash_type == INTEL28F160C3B) { return (FLASH_EraseBlock(index)); } else { return -1; }}int ROM_ReadBlock(U8 flash_type, int dev, U16 index, U8* buf, U32 count){ if(flash_type == NAND_FLASH) { return (read(dev, buf, count, &index)); } else if(flash_type == INTEL28F160C3B) { return (FLASH_ReadBlock(index, (U16 *)buf, (count / 2))); } else { return 0; }}int ROM_WriteBlock(U8 flash_type, int dev,U16 index,U8* buf,U32 count){ //int i; if(flash_type == NAND_FLASH) { return (write(dev, buf, count, &index)); } else if(flash_type == INTEL28F160C3B) { return (FLASH_WriteBlock(index, (U16 *)buf, (count / 2))); } else { return 0; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -