You are currently viewing the documentation for:
ECF_CreatePartitionTable
The ECF_CreatePartitionTable function creates an empty partition table. If one exists, it will be overwritten.
ECF_ErrorCode ECF_CreatePartitionTable(
   struct ECF_BlockDriver *pBlockDriver,
   uint16_t flags
);
Parameters
pBlockDriver
This is a pointer to a struct ECF_BlockDriver of the disk you want to create the partition table on.
flags
Flags. No flags are currently defined, specify 0.
Return value
Returns one of the EcFAT error codes (ECFERR_SUCCESS on success)
Remarks
You need to specify ECF_OPT_SUPPORT_FORMAT in your Project.h for EcFAT to compile with support for this function.
Example Code
void InitializeDisk(struct ECF_BlockDriver *blockDriver)
{
   // Error checking omitted, sector size of 512 assumed.

   // Initialize the partition table
   ECF_CreatePartitionTable(blockDriver, 0);
   
   // Create partition 1: A 2 MiB FAT partition for configuration
   ECF_CreatePartition(blockDriver, ECF_PARTITION_TYPE_FAT, 2*1024*1024/512, 0);

   // Create partition 2: A 10 MiB FAT partition for logs
   ECF_CreatePartition(blockDriver, ECF_PARTITION_TYPE_FAT, 10*1024*1024/512, 0);

   // Create partition 3: The rest of the space as a RAW partition
   // that we write data to directly
   ECF_CreatePartition(blockDriver, ECF_PARTITION_TYPE_RAW, 0, 0);
   
   // Format partition 1
   ECF_Format(blockDriver, 512, ECF_FORMAT_PARTITION1);

   // Format partition 2
   ECF_Format(blockDriver, 512, ECF_FORMAT_PARTITION2);
}
See also