📄 flash.h
字号:
#ifndef FLASH_CONTROL_MODULE
#define FLASH_CONTROL_MODULE
#include "../S3C44B0X/44B.h"
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
#define FLASH_LOCK_SUPPORTED 0
#define FLASH_TIMEOUT 1000000
#define FLASHFUNCSIZE 320
#define FLASH_BANK0_BASE_ADDR 0x000000
#define datasize 0x400
#define WIDTH 2
#define ftype volatile unsigned short
#define Write_aa_to_5555() (*(ftype *)(FLASH_BANK0_BASE_ADDR+(0x5555<<1)) = 0xaaaa)
#define Write_55_to_2aaa() (*(ftype *)(FLASH_BANK0_BASE_ADDR+(0x2aaa<<1)) = 0x5555)
#define Write_80_to_5555() (*(ftype *)(FLASH_BANK0_BASE_ADDR+(0x5555<<1)) = 0x8080)
#define Write_a0_to_5555() (*(ftype *)(FLASH_BANK0_BASE_ADDR+(0x5555<<1)) = 0xa0a0)
#define Write_f0_to_5555() (*(ftype *)(FLASH_BANK0_BASE_ADDR+(0x5555<<1)) = 0xf0f0)
#define Write_90_to_5555() (*(ftype *)(FLASH_BANK0_BASE_ADDR+(0x5555<<1)) = 0x9090)
#define Write_20_to_5555() (*(ftype *)(FLASH_BANK0_BASE_ADDR+(0x5555<<1)) = 0x2020)
#define Write_30_to_(add) (*(ftype *)add = 0x3030)
#define Read_0000() (*(ftype *)(FLASH_BANK0_BASE_ADDR+(0x0000<<1)))
#define Read_0001() (*(ftype *)(FLASH_BANK0_BASE_ADDR+(0x0001<<1)))
#define Read_5555() (*(ftype *)(FLASH_BANK0_BASE_ADDR+(0x5555<<1)))
#define Is_ff(add) (*(ftype *)add == 0xffff)
#define Is_not_ff(add) (*(ftype *)add != 0xffff)
#define D5_Timeout(add) ((*(ftype *)add & 0x1010) == 0x1010)
#define D3_Timeout(add) ((*(ftype *)add & 0x0404) == 0x0404)
#define Fwrite(to,frm) (*(ftype *)to = *(ftype *)frm)
#define Is_Equal(p1,p2) (*(ftype *)p1 == *(ftype *)p2)
#define Is_Not_Equal(p1,p2) (*(ftype *)p1 != *(ftype *)p2)
/* Device ID used for ram that is "pretending" to be a flash bank. */
#define FLASHRAM 0x9999
typedef struct tagFlashDesc
{
unsigned long id; // 厂商及设备 ID
char *desc; // 设备描述字符串
}
FlashDesc;
typedef struct tagSectorInfo
{
long size; // 扇区大小
int snum; // 扇区数 (amongst possibly several devices) */
int protected; // 窗口保护状态
BYTE *begin; // 扇区基地址
BYTE *end; // 扇区结束地址
}
SectorInfo;
typedef struct flashinfo
{
unsigned long id; // 厂商及设备ID
BYTE *base; // 设备基地址
BYTE *end; // 设备终止地址
int sectorcnt; // 扇区数
int width; // 单位宽度:1=8位,2=16位,4=32位
SectorInfo *sectors;
}
FlashInfo;
// Flash 相关信息定义
#define FLASH_TOTAL_SIZE 4 * 1024 * 1024 // Flash 总容量大小(字节)
#define FLASH_PAGE_SIZE 64 * 1024 // Flash 页面大小(字节)
#define FLASH_PAGE_NUM 63 // Flash 块数量
// 取Flash块的起始地址
#define GetFlashPageAddress(n) ((n)*FLASH_PAGE_SIZE)
// 用于判定数据操作成功或失败的宏(仅在文件系统内部使用)
#define OPERATION_FAIL 0xFFFFFFFF
#define SUCCESS(n) ((n)!=OPERATION_FAIL)
#define FAILED(n) ((n)==OPERATION_FAIL)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
extern WORD bFlashOperationEnabled;
extern int flashtype(FlashInfo *);
extern int FLASHWRITE(ftype *,ftype *,unsigned long bytecnt);
extern int ReadFlash(long dest, BYTE *buf, unsigned long bytecnt);
extern int EraseFlash(int);
#define WriteFlash(uAddr,pBuf,uSize) FLASHWRITE((ftype*)(uAddr), (ftype*)(pBuf), (unsigned long)(uSize))
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -