⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fs_fformat.c

📁 keil arm flash fs 最新版 在Keil arm下使用
💻 C
字号:
/*----------------------------------------------------------------------------
 *      R T L  -  F l a s h   F i l e   S y s t e m
 *----------------------------------------------------------------------------
 *      Name:    FS_FFORMAT.C 
 *      Purpose: File System Format Function
 *      Rev.:    V3.22
 *----------------------------------------------------------------------------
 *      This code is part of the RealView Run-Time Library.
 *      Copyright (c) 2004-2008 KEIL - An ARM Company. All rights reserved.
 *---------------------------------------------------------------------------*/

#include "File_Config.h"

/*--------------------------- fformat ---------------------------------------*/

int fformat (const char *drive) {
   /* Format the FlashFS storage media. This function call is required  */
   /* before first use of the FlashFS to initialize the storage device. */
   IOB *fcb,*iop;
   int handle;
   U32 i;

   /* Find an unused _iob structure. */
   if ((handle = fs_find_iob ()) == EOF) {
      return (1);
   }
   fcb = &_iob[handle];
   /* Get the drive index. */
   fcb->drive = fs_get_drive (drive);
   if (fcb->drive != DRV_NONE) {
      /* Skip drive letter 'X:' */
      drive += 2;
   }
   else {
      /* Empty string or label provided. */
      fcb->drive = _DEF_DRIVE;
   }
   if (fcb->drive == DRV_MCARD) {
      /* Format a Flash Card. */
      if (fat_format (drive) == __TRUE) {
         return (0);
      }
      /* FAT formatting error. */
      return (1);
   }
   /* Set drive parameters. */
   if (fs_set_params (fcb) == __FALSE) {
      return (1);
   }

   /* Reset any opened file handles for this drive */
   for (i = 0, iop = &_iob[0]; i < _NFILE; i++, iop++) {
      if (iop->drive != fcb->drive) {
         continue;
      }
      if (iop->flags & (_IOREAD|_IOWRT)) {
         iop->flags  = 0;
         iop->fileID = 0;
      }
   }
   for (i = 0; i < fcb->NumSect; i++) {
      if (fs_InitBlock (i, fcb) == __FALSE) {
         /* Error, return nonzero value. */
         return (1);
      }
   }
   return (0);
}

/*----------------------------------------------------------------------------
 * end of file
 *---------------------------------------------------------------------------*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -