?? norflash.c
字號(hào):
#include "config.h"
uchar norflash_check(uint dst)
{
uchar SR;
uint i = 0;
uint j = 0;
*(pchar)dst = 0x70;
SR = *(pchar)dst;
if((SR & 0x80) == 0x80)
return TRUE;
else
return FALSE;
}
void norflash_erase_block(uint dst)
{
uint i;
uchar ReturnStatus;
*(pchar)dst = 0x20;
*(pchar)dst = 0xd0;
//for(i=0;i<5000;i++);
while(1)
{
ReturnStatus = norflash_check(dst);
if(ReturnStatus) break;
}
*(pchar)dst = 0x50;
*(pchar)dst = 0xff;
}
void norflash_write_char(uint dst , uchar src)
{
uint i;
uchar ReturnStatus;
*(pchar)dst = 0x40;
*(pchar)dst = src;
//for(i=0;i<10;i++);
while(1)
{
ReturnStatus = norflash_check(dst);
if(ReturnStatus) break;
}
*(pchar)dst = 0x50;
*(pchar)dst = 0xff;
}
uchar norflash_read_char(uint dst)
{
uchar i;
*(pchar)dst = 0xff;
i = *(pchar)dst;
return i;
}
void norflash_reset(uint dst)
{
*(pchar)dst = 0xff;
}
uint norflash_address_convert(ulong src)
{
uint dst;
uint CS;
if(src < 0x100000)
{
CS = 0xb000;
}
else if(src < 0x200000)
{
src -= 0x100000;
CS = 0xc000;
}
*(pchar)0x8000 = src >> 12;
src &= 0x0fff;
dst = src;
dst += CS;
return dst;
}
void norflash_write_str(uint dst ,uchar *src ,uint size)
{
uchar ReturnStatus;
uint i;
uchar data;
for(i=0;i<size;i++)
{
data = *(src++);
norflash_write_char(dst++,data);
}
}
uchar norflash_read_str(uint src ,uint size)
{
uint i;
uchar *dst ;
*(pchar)src = 0xff;
for(i=0;i<size;i++)
{
*(dst++) = norflash_read_char(src++);
}
return *dst;
}
void norflash_write_int(uint dst, uint src)
{
norflash_write_char(dst++,src>>8);
norflash_write_char(dst++,src);
}
uint norflash_read_int(uint src)
{
uchar i, j;
*(pchar)src = 0xff;
i = norflash_read_char(src++);
j = norflash_read_char(src++);
return ((i<<8) + j) ;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -