资源简介
该1代码可以使用,只需配置参数和添加底层接口,我找了好久才找到的。
代码片段和文件信息
#ifndef _FIL_BAD_C_
#define _FIL_BAD_C_
/****************************************************************************
*
* Copyright (c) 2005 by HCC embedded
*
* This software is copyrighted by and is the sole property of
* HCC. All rights title ownership or other interests
* in the software remain the property of HCC. This
* software may only be used in accordance with the corresponding
* license agreement. Any unauthorized use duplication transmission
* distribution or disclosure of this software is expressly forbidden.
*
* This Copyright notice may not be removed or modified without prior
* written consent of HCC.
*
* HCC reserves the right to modify this software without notice.
*
* HCC embedded
* Budapest 1132
* Victor Hugo Utca 11-15
* Hungary
*
* Tel: +36 (1) 450 1302
* Fax: +36 (1) 450 1303
* http: www.hcc-embedded.com
* email: info@hcc-embedded.com
*
***************************************************************************/
/****************************************************************************
*
* Bad Block handling
*
***************************************************************************/
#include “llayer.h“
#include “mlayer.h“
#include “fil_wear.h“
#include “fil_bad.h“
/****************************************************************************
*
* variables
*
***************************************************************************/
/****************************************************************************
*
* bb_getmaxreserved
*
* retreives the number of reserved block valid only after bb_init
*
* RETURNS
*
* number of used reserved entry
*
***************************************************************************/
unsigned short bb_getmaxreserved() {
return gl_mlayer->bad_maxentry;
}
/****************************************************************************
*
* bb_init
*
* initializing bad block handler this must be called at power on after
* flash type are determined after map page loaded
*
* INPUTS
*
* maxentry - maximum number of entries
*
***************************************************************************/
unsigned char bb_init(unsigned short maxentry) {
ST_SPARE *sptr=GET_SPARE_AREA(gl_mlayer->badpagebuffer);
unsigned short a;
unsigned char ret;
if (maxentry > (MAX_DATA_SIZE/2)) maxentry=(MAX_DATA_SIZE/2); //maximum allowed in one page!
gl_mlayer->bad_table=(t_ba*)gl_mlayer->badpagebuffer; //set up pointer
gl_mlayer->bad_maxentry=maxentry;
gl_mlayer->bad_init_index=0;
if (gl_mlayer->badblock->pba==BLK_NA) ret=0xf0; //not exist
else if (gl_mlayer->badblock->ppo>=MAX_PAGE_PER_BLOCK) ret=0xf1; //invalid page
else ret=ll_read((t_ba)(gl_mlayer->start_pba+gl_mlayer->badblock->pba)gl_mlayer->badblock->ppogl_mlayer->badpagebuffer);
if (!ret) {
if (sptr->block_type!=BLK_TYPE_BAD) ret=0xf2; //it is corre
- 上一篇:51单片机爱心.zip
- 下一篇:ssh航空订票系统
评论
共有 条评论