Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added API allowing user to choose settings at runtime #49

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions portable/Zynq.2019.3/ff_sddisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,17 +432,19 @@ static CacheMemoryInfo_t * pucGetSDIOCacheMemory( BaseType_t xPartition )
}
/*-----------------------------------------------------------*/

/* Initialise the SDIO driver and mount an SD card */
BaseType_t xMountFailIgnore = 0;
FF_Disk_t * FF_SDDiskInit( const char * pcName )
{
return FF_SDDiskInitWithSettings( pcName, pdFALSE, 0U );
}

/* _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'.
/**
* Initialize the SD Disk with configurable settings
* @param[in] uxMountFailIgnore ignore fails on mount, set to true when have systems where may not have initialized mount
* @param[in] uxDiskPartition the disk partition number to use
*/
BaseType_t xDiskPartition = 0;

FF_Disk_t * FF_SDDiskInit( const char * pcName )
FF_Disk_t * FF_SDDiskInitWithSettings( const char * pcName,
BaseType_t xMountFailIgnore,
BaseType_t xDiskPartition )
Comment on lines +440 to +447
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One slight change to allow for future proofing this.

Suggest putting all of the settings into a struct:

typedef struct FFInitSettings_s
{
BaseType_t xMountFailIgnore;
BaseType_t xDiskPartition;
} FFInitSettings_t;

And then change the API to:

FF_Disk_t * FF_SDDiskInitWithSettings( const char * pcName,
                                       const FFInitSettings_t * settings)

That way you can append to the settings later on without changing the API - as long as the defaults are something reasonable (most likely candidate) the API doesn't have to change for new initialization configuration settings.

@AniruddhaKanhere - you are also missing adding the API to the header file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phelter , yes a good idea to put it into a struct. The only obligation will be to clear all (unused) fields in the struct. Thanks, Hein

{
FF_Error_t xFFError;
BaseType_t xPartitionNumber = xDiskPartition;
Expand Down