📄 flashfunc.~pas
字号:
unit FlashFunc;
interface
implementation
{*----------------------------------------------------------------
* brief : check if the flash is empty in the give size
* author: guojian
* param: addr-----the first check address(0x0~0x1fffff)
size-----check size
* retval: 1--------not empty
0---------empty( all 0xff )
-1---------read error
* modify history:
if you change the function please give the discription
-----------------------------------------------------------------}
function blank_check(addr, size:word ):integer;
var
tmp:byte;
break_point:integer;
percent:integer;
i:integer;
begin
percent:=trunc(size/10);
//check first byte if addr is odd
if( addr % 2 ) {
tmp = sst_read_word( addr - 1 );
if( ( tmp >> 8 ) != 0xff )
return 1;
//the first byte is empty
size--;
addr++;
}
//if read size is odd
if( size % 2 )
break_point = 1;
else
break_point = 0;
//very time we check 2 byte
i = 0;
while( size != break_point ) {
tmp = sst_read_word( addr );
if( tmp != 0xffff )
return 1;
//prepare for next check
size = size - 2;
addr = addr + 2;
//count the blank check percent
if( size < percent * ( 10 - i ) ) {
printf( "finished blank check %d %%\n ", i*10 );
i++;
}
}
printf( "\n" );
if( size == 0 )
return 0;
//check the last byte
tmp = sst_read_word( addr );
if( ( tmp & 0x00ff ) != 0xff )
return 1;
Result:=0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -