下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

最新资讯
简化任何设备的身份验证云连接。
利用 CoAP 设计节能型云连接 IoT 解决方案。
11.0.0 版 FreeRTOS 内核简介:
FreeRTOS 路线图和代码贡献流程。
使用 FreeRTOS 实现 OPC-UA over TSN。

FF_Partition() [FreeRTOS-Plus-FAT 原生 API 引用]

ff_format.h  
FF_Error_t FF_Partition( FF_Disk_t *pxDisk, FF_PartitionParameters *pxFormatParameters );
  媒体是用于存储文件的物理设备。适用于 嵌入式文件系统的媒体的示例包括 SD 卡, 固态磁盘、NOR 闪存芯片、NAND 闪存芯片和 RAM 芯片。 媒体不能用于保存 FreeRTOS-Plus-FAT 文件系统,直至它 被分区。 将媒体划分为多个单元,每个单元 被称为一个分区。然后,可以对每个分区进行格式化 以保存其文件系统。 通过一个 FF_PartitionParameters 类型结构体对媒体分区方法进行描述,如下所示。若要创建用于填充媒体上所有可用空间 的单个分区,只需将 结构体的 xSizes 和 xPrimaryCount 保留为零。

typedef enum _FF_SizeType
{
/* xSizes within the FF_PartitionParameters structure are specified as a
quotum (the sum of all xSizes is free, all disk space will be allocated). */

eSizeIsQuota,

/* xSizes within the FF_PartitionParameters structure are specified as a
percentage of the total disk space (the sum of all xSizes must be <= 100%) */

eSizeIsPercent,

/* xSizes within the FF_PartitionParameters structure are specified as a
number of sectors (the sum of all xSizes must be < ulSectorCount). */

FF_Size_Sectors,
} eSizeType_t;

typedef struct _FF_PartitionParameters
{
/* The total number of sectors on the media, including hidden/reserved
sectors. */

uint32_t ulSectorCount;

/* The number of sectors to keep free. */
uint32_t ulHiddenSectors;

/* The number of sectors to keep between partitions. */
uint32_t ulInterSpace;

/* The size of each partition - how the sizes are specified depends on the
value of eSizeType. */

BaseType_t xSizes[ FF_MAX_PARTITIONS ];

/* The number of primary partitions to create. */
BaseType_t xPrimaryCount;

/* How the values within the xSizes array are specified. */
eSizeType_t eSizeType;
} FF_PartitionParameters;

The FF_PartitionParameters and associated types
参数:
pxDisk 描述被分区的媒体的 FF_Disk_t 结构体 。 
FF_FormatParameters 指针,指向描述如何对媒体进行分区的 结构体。  
返回: 如果媒体分区成功,则返回 FF_ERR_NONE。 如果无法对媒体进行分区,则返回错误代码。 FF_GetErrMessage() 可将错误代码转换为错误描述。 用法示例:

#define HIDDEN_SECTOR_COUNT 8
#define PRIMARY_PARTITIONS 1
#define PARTITION_NUMBER 0

static FF_Error_t prvPartitionAndFormatDisk( FF_Disk_t *pxDisk )
{
FF_PartitionParameters xPartition;
FF_Error_t xError;

/* Media cannot be used until it has been partitioned. In this
case a single partition is to be created that fills all available space - so
by clearing the xPartition structure to zero. */

memset( &xPartition, 0x00, sizeof( xPartition ) );
xPartition.ulSectorCount = pxDisk->ulNumberOfSectors;
xPartition.ulHiddenSectors = HIDDEN_SECTOR_COUNT;
xPartition.xPrimaryCount = PRIMARY_PARTITIONS;
xPartition.eSizeType = eSizeIsQuota;

/* Perform the partitioning. */
xError = FF_Partition( pxDisk, &xPartition );

/* Print out the result of the partition operation. */
FF_PRINTF( "FF_Partition: FF_Format: %sn", FF_GetErrMessage( xError ) );

/* Was the disk partitioned successfully? */
if( FF_isERR( xError ) == pdFALSE )
{
/* The disk was partitioned successfully. Format the first partition. */
xError = FF_Format( pxDisk, ramPARTITION_NUMBER, pdTRUE, pdTRUE );

/* Print out the result of the format operation. */
FF_PRINTF( "FF_RAMDiskInit: FF_Format: %sn", FF_GetErrMessage( xError ) );
}

return xError;
}

Using the FF_Partition() and FF_Format() functions to partition the disk, then format a partition
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.