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

📄 fs_norsectorinfo.c

📁 ucfs文件系统pc版的demo演示
💻 C
字号:
/*
**********************************************************************
*                          Micrium, Inc.
*                      949 Crestview Circle
*                     Weston,  FL 33327-1848
*
*                            uC/FS
*
*             (c) Copyright 2001 - 2006, Micrium, Inc.
*                      All rights reserved.
*
***********************************************************************

----------------------------------------------------------------------
----------------------------------------------------------------------
File        : NORSectorInfo.c
Purpose     : Check the infos of all phjysical sectors.
---------------------------END-OF-HEADER------------------------------
*/

#include <string.h>
#include <stdio.h>
#include "FS.h"

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/

/*********************************************************************
*
*       ShowDiskInfo
*
*/
void ShowDiskInfo(FS_NOR_DISK_INFO* pDiskInfo) {
  char acBuffer[80];

  FS_X_Log("Disk Info: \n");
  FS_NOR_GetDiskInfo(0, pDiskInfo); 
  sprintf(acBuffer," Physical sectors: %d\n"
                   " Logical sectors : %d\n" 
                   " Used sectors: %d\n", pDiskInfo->NumPhysSectors, pDiskInfo->NumLogSectors, pDiskInfo->NumUsedSectors);
  FS_X_Log(acBuffer);
}

/*********************************************************************
*
*       ShowSectorInfo
*/
void ShowSectorInfo(FS_NOR_SECTOR_INFO* pSecInfo, U32 PhysSectorIndex) {
  char acBuffer[400];

  FS_X_Log("Sector Info: \n");
  FS_NOR_GetSectorInfo(0, PhysSectorIndex, pSecInfo);
  sprintf(acBuffer," Physical sector No.     : %d\n"
                   " Offset                  : %d\n"
                   " Size                    : %d\n"
                   " Erase Count             : %d\n" 
                   " Used logical sectors    : %d\n"
                   " Free logical sectors    : %d\n" 
                   " Erasable logical sectors: %d\n", PhysSectorIndex, pSecInfo->Off, pSecInfo->Size, pSecInfo->EraseCnt, pSecInfo->NumUsedSectors, pSecInfo->NumFreeSectors, pSecInfo->NumEraseableSectors);
  FS_X_Log(acBuffer);
}

/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  U32                i, j;
  char               ac[0x400];
  FS_NOR_DISK_INFO   DiskInfo;
  FS_NOR_SECTOR_INFO SecInfo;

  FS_FILE * pFile;  
  FS_Init();
  FS_FormatLLIfRequired("");
  for(i = 0; i < strlen(ac); i++) {
    ac[i] = 'A';
  }
  //
  // Check if volume needs to be high level formatted.
  //
  if (FS_IsHLFormatted("") == 0) {
    printf("High level formatting\n");
    FS_Format("", NULL);
  }
  ShowDiskInfo(&DiskInfo);
  for (i = 0;  i < 1000; i++) {
    pFile = FS_FOpen("Test.txt","w");
    if(pFile != 0) {
      FS_Write(pFile, &ac, strlen(ac));
      FS_FClose(pFile);
      printf("Loop cycle: %d\n", i);
      for(j = 0; j < DiskInfo.NumPhysSectors; j++) {
        ShowSectorInfo(&SecInfo, j);
      }
    }
  }
  while(1);
}


/*************************** End of file ****************************/

⌨️ 快捷键说明

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