mirror of
https://github.com/FreeRTOS/Lab-Project-FreeRTOS-FAT.git
synced 2025-10-17 07:21:22 +08:00
Added API allowing user to choose settings at runtime - replacement of PR#49 (#51)
* Adding in FF_SDDiskInitWithSettings optional initialization to support runtime initial mounting options. * FAT-#50: Fixing duplicate definition of st_atime, st_mtime, st_ctime for linux. * Fixing formatting with diff provided using uncrustify. --------- Co-authored-by: Paul Helter <paulheltera@gmail.com>
This commit is contained in:

committed by
GitHub

parent
08d0cff40d
commit
25129e5221
@@ -1137,9 +1137,9 @@ int ff_stat( const char * pcName,
|
||||
|
||||
#if ( ffconfigTIME_SUPPORT == 1 )
|
||||
{
|
||||
pxStatBuffer->st_atime = prvFileTime( &( xDirEntry.xAccessedTime ) );
|
||||
pxStatBuffer->st_mtime = prvFileTime( &( xDirEntry.xModifiedTime ) );
|
||||
pxStatBuffer->st_ctime = prvFileTime( &( xDirEntry.xCreateTime ) );
|
||||
pxStatBuffer->ff_atime = prvFileTime( &( xDirEntry.xAccessedTime ) );
|
||||
pxStatBuffer->ff_mtime = prvFileTime( &( xDirEntry.xModifiedTime ) );
|
||||
pxStatBuffer->ff_ctime = prvFileTime( &( xDirEntry.xCreateTime ) );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -89,9 +89,9 @@
|
||||
|
||||
/* Note time_t must be used here otherwise will have bugs when 2032 (uint32_t second clock rolls over) */
|
||||
#if ( ffconfigTIME_SUPPORT == 1 )
|
||||
time_t st_atime;
|
||||
time_t st_mtime;
|
||||
time_t st_ctime;
|
||||
time_t ff_atime;
|
||||
time_t ff_mtime;
|
||||
time_t ff_ctime;
|
||||
#endif /* ffconfigTIME_SUPPORT */
|
||||
} FF_Stat_t;
|
||||
|
||||
|
@@ -310,6 +310,15 @@ void FF_SDDiskFlush( FF_Disk_t * pxDisk )
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
FF_Disk_t * FF_SDDiskInitWithSettings( const char * pcName,
|
||||
const FFInitSettings_t * pxSettings )
|
||||
{
|
||||
( void ) pxSettings; /* Unused */
|
||||
|
||||
return FF_SDDiskInit( pcName );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Initialise the SDIO driver and mount an SD card */
|
||||
FF_Disk_t * FF_SDDiskInit( const char * pcName )
|
||||
{
|
||||
|
@@ -168,6 +168,15 @@ void FF_SDDiskFlush( FF_Disk_t * pxDisk )
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
FF_Disk_t * FF_SDDiskInitWithSettings( const char * pcName,
|
||||
const FFInitSettings_t * pxSettings )
|
||||
{
|
||||
( void ) pxSettings; /* Unused */
|
||||
|
||||
return FF_SDDiskInit( pcName );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Initialise the SDIO driver and mount an SD card */
|
||||
FF_Disk_t * FF_SDDiskInit( const char * pcName )
|
||||
{
|
||||
|
@@ -423,6 +423,15 @@ static void vGPIO_SD_Init( SD_HandleTypeDef * xSDHandle )
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
FF_Disk_t * FF_SDDiskInitWithSettings( const char * pcName,
|
||||
const FFInitSettings_t * pxSettings )
|
||||
{
|
||||
( void ) pxSettings; /* Unused */
|
||||
|
||||
return FF_SDDiskInit( pcName );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
FF_Disk_t * FF_SDDiskInit( const char * pcName )
|
||||
{
|
||||
FF_Error_t xFFError;
|
||||
|
@@ -539,6 +539,15 @@ static void vGPIO_SD_Init( SD_HandleTypeDef * xSDHandle )
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
FF_Disk_t * FF_SDDiskInitWithSettings( const char * pcName,
|
||||
const FFInitSettings_t * pxSettings )
|
||||
{
|
||||
( void ) pxSettings; /* Unused */
|
||||
|
||||
return FF_SDDiskInit( pcName );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
FF_Disk_t * FF_SDDiskInit( const char * pcName )
|
||||
{
|
||||
FF_Error_t xFFError;
|
||||
|
@@ -432,20 +432,19 @@ static CacheMemoryInfo_t * pucGetSDIOCacheMemory( BaseType_t xPartition )
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Initialise the SDIO driver and mount an SD card */
|
||||
BaseType_t xMountFailIgnore = 0;
|
||||
|
||||
/* _HT_ : the function FF_SDDiskInit() used to mount partition-0.
|
||||
* It would be nice if it has a parameter indicating the partition
|
||||
* number.
|
||||
* As for now, the partion can be set with a global variable 'xDiskPartition'.
|
||||
*/
|
||||
BaseType_t xDiskPartition = 0;
|
||||
|
||||
FF_Disk_t * FF_SDDiskInit( const char * pcName )
|
||||
{
|
||||
const FFInitSettings_t defaultSettings = {};
|
||||
|
||||
return FF_SDDiskInitWithSettings( pcName, &defaultSettings );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Initialise the SDIO driver and mount an SD card */
|
||||
FF_Disk_t * FF_SDDiskInitWithSettings( const char * pcName,
|
||||
const FFInitSettings_t * pxSettings )
|
||||
{
|
||||
FF_Error_t xFFError;
|
||||
BaseType_t xPartitionNumber = xDiskPartition;
|
||||
FF_CreationParameters_t xParameters;
|
||||
FF_Disk_t * pxDisk = NULL;
|
||||
CacheMemoryInfo_t * pxCacheMem = NULL;
|
||||
@@ -456,13 +455,13 @@ FF_Disk_t * FF_SDDiskInit( const char * pcName )
|
||||
|
||||
do
|
||||
{
|
||||
if( pucGetSDIOCacheMemory( xPartitionNumber ) == NULL )
|
||||
if( pucGetSDIOCacheMemory( pxSettings->xDiskPartition ) == NULL )
|
||||
{
|
||||
FF_PRINTF( "FF_SDDiskInit: Cached memory failed\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
pxCacheMem = pxCacheMemories[ xPartitionNumber ];
|
||||
pxCacheMem = pxCacheMemories[ pxSettings->xDiskPartition ];
|
||||
|
||||
if( pxSDCardInstance == NULL )
|
||||
{
|
||||
@@ -551,14 +550,14 @@ FF_Disk_t * FF_SDDiskInit( const char * pcName )
|
||||
}
|
||||
|
||||
pxDisk->xStatus.bIsInitialised = pdTRUE;
|
||||
pxDisk->xStatus.bPartitionNumber = xPartitionNumber;
|
||||
pxDisk->xStatus.bPartitionNumber = pxSettings->xDiskPartition;
|
||||
|
||||
if( FF_SDDiskMount( pxDisk ) == 0 )
|
||||
{
|
||||
/* _HT_ Suppose that the partition is not yet
|
||||
* formatted, it might be desireable to have a valid
|
||||
* i/o manager. */
|
||||
if( xMountFailIgnore == 0 )
|
||||
if( pxSettings->xMountFailIgnore == 0 )
|
||||
{
|
||||
FF_SDDiskDelete( pxDisk );
|
||||
pxDisk = NULL;
|
||||
|
@@ -371,6 +371,15 @@ static struct xCACHE_MEMORY_INFO * pucGetSDIOCacheMemory()
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
FF_Disk_t * FF_SDDiskInitWithSettings( const char * pcName,
|
||||
const FFInitSettings_t * pxSettings )
|
||||
{
|
||||
( void ) pxSettings; /* Unused */
|
||||
|
||||
return FF_SDDiskInit( pcName );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Initialise the SDIO driver and mount an SD card */
|
||||
FF_Disk_t * FF_SDDiskInit( const char * pcName )
|
||||
{
|
||||
|
12
portable/common/ff_sddisk.h
Executable file → Normal file
12
portable/common/ff_sddisk.h
Executable file → Normal file
@@ -28,11 +28,18 @@
|
||||
|
||||
#define __SDDISK_H__
|
||||
|
||||
#include "ff_headers.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ff_headers.h"
|
||||
/* @brief Initialization settings for more granular control on init. */
|
||||
typedef struct FFInitSettings_s
|
||||
{
|
||||
BaseType_t xMountFailIgnore; /**< Ignore failure when mounting */
|
||||
BaseType_t xDiskPartition; /**< Default disk partition number */
|
||||
} FFInitSettings_t;
|
||||
|
||||
|
||||
/* Return non-zero if the SD-card is present.
|
||||
@@ -40,6 +47,9 @@
|
||||
BaseType_t FF_SDDiskDetect( FF_Disk_t * pxDisk );
|
||||
|
||||
/* Create a RAM disk, supplying enough memory to hold N sectors of 512 bytes each */
|
||||
FF_Disk_t * FF_SDDiskInitWithSettings( const char * pcName,
|
||||
const FFInitSettings_t * pxSettings );
|
||||
|
||||
FF_Disk_t * FF_SDDiskInit( const char * pcName );
|
||||
|
||||
BaseType_t FF_SDDiskReinit( FF_Disk_t * pxDisk );
|
||||
|
@@ -74,6 +74,15 @@ void FF_SDDiskFlush( FF_Disk_t * pxDisk )
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
FF_Disk_t * FF_SDDiskInitWithSettings( const char * pcName,
|
||||
const FFInitSettings_t * pxSettings )
|
||||
{
|
||||
( void ) pxSettings; /* Unused */
|
||||
|
||||
return FF_SDDiskInit( pcName );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
FF_Disk_t * FF_SDDiskInit( const char * pcName )
|
||||
{
|
||||
FF_Disk_t * pxDisk = NULL;
|
||||
|
@@ -188,7 +188,15 @@ void FF_SDDiskFlush( FF_Disk_t * pxDisk )
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Initialise the SDIO driver and mount an SD card */
|
||||
FF_Disk_t * FF_SDDiskInitWithSettings( const char * pcName,
|
||||
const FFInitSettings_t * pxSettings )
|
||||
{
|
||||
( void ) pxSettings; /* Unused */
|
||||
|
||||
return FF_SDDiskInit( pcName );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
FF_Disk_t * FF_SDDiskInit( const char * pcName )
|
||||
{
|
||||
FF_Error_t xFFError;
|
||||
|
Reference in New Issue
Block a user