FreeRTOS+FAT is still in the lab
FreeRTOS+FAT is already in use in commercial products
and we encourage you to try it yourself. Be aware however that
FreeRTOS+FAT was acquired by Real Time Engineers Ltd., and is
still being documented and updated to
ensure it meets our strict quality standards.
Please use the forum for support,
or contact us directly if you have a specific business interest.
Actions performed within a media driver's initialisation
function (* optional steps)
The media driver's initialisation function must allocate an
FF_Disk_t
structure for use with the media.
The FF_Disk_t structure contains a pointer to an FF_IOManager_t structure.
The FF_IOManager_t structure is created by calling
FF_CreateIOManager().
For convenience, the media driver can
optionally also mount a partition
on the media, and add the mounted
partition to FreeRTOS+FAT's virtual file system. Performing these two
optional steps within the initialisation function removes the need for
the application writer to perform them explicitly. The image on the right
shows the media driver's initialisation function performing these
optional steps.
Worked Example
As an example, below is the outline of the media driver initialisation
function used by the FreeRTOS+FAT RAM disk driver. The full version,
which includes additional error checking, can be found in
/FreeRTOS-Plus/Source/FreeRTOS-Plus-FAT/portable/common/ff_ramdisk.c.
#define ramSECTOR_SIZE 512UL
#define ramPARTITION_NUMBER 0
FF_Disk_t *FF_RAMDiskInit( char *pcName,
uint8_t *pucDataBuffer,
uint32_t ulSectorCount,
size_t xIOManagerCacheSize )
{
FF_Error_t xError;
FF_Disk_t *pxDisk = NULL;
FF_CreationParameters_t xParameters;
configASSERT( ( xIOManagerCacheSize % ramSECTOR_SIZE ) == 0 );
configASSERT( ( xIOManagerCacheSize >= ( 2 * ramSECTOR_SIZE ) ) );
pxDisk = ( FF_Disk_t * ) pvPortMalloc( sizeof( FF_Disk_t ) );
if( pxDisk != NULL )
{
memset( pxDisk, '\0', sizeof( FF_Disk_t ) );
pxDisk->pvTag = ( void * ) pucDataBuffer;
pxDisk->ulSignature = ramSIGNATURE;
pxDisk->ulNumberOfSectors = ulSectorCount;
memset (&xParameters, '\0', sizeof xParameters);
xParameters.pucCacheMemory = NULL;
xParameters.ulMemorySize = xIOManagerCacheSize;
xParameters.ulSectorSize = ramSECTOR_SIZE;
xParameters.fnWriteBlocks = prvWriteRAM;
xParameters.fnReadBlocks = prvReadRAM;
xParameters.pxDisk = pxDisk;
xParameters.pvSemaphore = ( void * ) xSemaphoreCreateRecursiveMutex();
xParameters.xBlockDeviceIsReentrant = pdTRUE;
pxDisk->pxIOManager = FF_CreateIOManger( &xParameters, &xError );
if( ( pxDisk->pxIOManager != NULL ) && ( FF_isERR( xError ) == pdFALSE ) )
{
pxDisk->xStatus.bIsInitialised = pdTRUE;
xError = prvPartitionAndFormatDisk( pxDisk );
if( FF_isERR( xError ) == pdFALSE )
{
pxDisk->xStatus.bPartitionNumber = ramPARTITION_NUMBER;
xError = FF_Mount( pxDisk, ramPARTITION_NUMBER );
}
if( FF_isERR( xError ) == pdFALSE )
{
FF_FS_Add( pcName, pxDisk->pxIOManager );
}
}
else
{
FF_RAMDiskDelete( pxDisk );
pxDisk = NULL;
}
}
return pxDisk;
}
The outline of a media driver's initialisation function
|
|
|
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.