File System Driver

The file system driver is used for the reading and writing of files.

Data Structures

ATMO_FILESYSTEM_Config_t

File system driver configuration.

Member Name Type Description
numRetries unsigned int Number of retries on a file system operation failure
retryDelayMs unsigned int How long to wait (in milliseconds) before retrying

Type Definitions

Name Definition
ATMO_FILESYSTEM_DriverInstance_t typedef struct ATMO_FILESYSTEM_DriverInstance_t

Enumerations

enum ATMO_FILESYSTEM_Status_t

File system function return enumerations.

Name Value Description
ATMO_FILESYSTEM_Status_Success 0x00u Common - Operation was successful
ATMO_FILESYSTEM_Status_Fail 0x01u Common - Operation failed
ATMO_FILESYSTEM_Status_Initialized 0x02u Common - Peripheral already initialized
ATMO_FILESYSTEM_Status_Invalid 0x03u Common - Invalid operation or result
ATMO_FILESYSTEM_Status_NotSupported 0x04u Common - Feature not supported by platform
ATMO_FILESYSTEM_Status_Unknown 0x05u Common - Some other status not defined

enum ATMO_FILESYSTEM_Open_Flags_t

File open flags.

Name Value Description
ATMO_RDONLY 1 Open a file as read only
ATMO_WRONLY 2 Open a file as write only
ATMO_RDWR 3 Open a file as read and write
ATMO_CREAT 0x0100 Create a file if it does not exist
ATMO_EXCL 0x0200 Fail if a file already exists
ATMO_TRUNC 0x0400 Truncate the existing file to zero size
ATMO_APPEND 0x0800 Move to end of file on every write
ATMO_NORETRY 0x1000 Don’t retry if open fails

enum ATMO_FILESYSTEM_Type_t

File type.

Name Value
ATMO_FILESYSTEM_Type_File  
ATMO_FILESYSTEM_Type_Dir  
ATMO_FILESYSTEM_Type_Unknown  

Functions

ATMO_Status_t ATMO_FILESYSTEM_AddDriverInstance(const ATMO_FILESYSTEM_DriverInstance_t *driverInstance, ATMO_DriverInstanceData_t *driverInstanceData, ATMO_DriverInstanceHandle_t *instanceNumber)

Parameter Direction Type
instanceNumber N/A ATMO_DriverInstanceHandle_t *
driverInstanceData N/A ATMO_DriverInstanceData_t *
driverInstance N/A const ATMO_FILESYSTEM_DriverInstance_t *
Return Type
ATMO_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_Init(ATMO_DriverInstanceHandle_t instanceNumber, ATMO_DriverInstanceHandle_t blockDriverHandle)

Initialize file system.

Parameter Direction Type
blockDriverHandle in ATMO_DriverInstanceHandle_t
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_SetConfiguration(ATMO_DriverInstanceHandle_t instanceNumber, const ATMO_FILESYSTEM_Config_t *config)

Set file system configuration.

Parameter Direction Type
config in const ATMO_FILESYSTEM_Config_t *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_Wipe(ATMO_DriverInstanceHandle_t instanceNumber)

Wipe the whole file system.

Parameter Direction Type
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_Mount(ATMO_DriverInstanceHandle_t instanceNumber)

Mount file system.

Parameter Direction Type
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_Unmount(ATMO_DriverInstanceHandle_t instanceNumber)

Unmount file system.

Parameter Direction Type
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_Remove(ATMO_DriverInstanceHandle_t instanceNumber, const char *path)

Remove file/directory.

Parameter Direction Type
path in const char *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_Rename(ATMO_DriverInstanceHandle_t instanceNumber, const char *oldPath, const char *newPath)

Rename file/directory.

Parameter Direction Type
newPath in const char *
oldPath in const char *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_Stat(ATMO_DriverInstanceHandle_t instanceNumber, ATMO_FILESYSTEM_Info_t *info, const char *path)

Get info about data at given path (type, size, etc.).

Parameter Direction Type
path in const char *
info out ATMO_FILESYSTEM_Info_t *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_FileOpen(ATMO_DriverInstanceHandle_t instanceNumber, ATMO_FILESYSTEM_File_t *file, const char *path, int flags)

Open file.

Parameter Direction Type
flags N/A int
path N/A const char *
file N/A ATMO_FILESYSTEM_File_t *
instanceNumber N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_FileClose(ATMO_DriverInstanceHandle_t instanceNumber, ATMO_FILESYSTEM_File_t *file)

Close file.

Parameter Direction Type
file in ATMO_FILESYSTEM_File_t *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_FileSync(ATMO_DriverInstanceHandle_t instanceNumber, ATMO_FILESYSTEM_File_t *file)

Sync file with underlying block driver.

Parameter Direction Type
file N/A ATMO_FILESYSTEM_File_t *
instanceNumber N/A ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_FileRead(ATMO_DriverInstanceHandle_t instanceNumber, ATMO_FILESYSTEM_File_t *file, void *buffer, uint32_t size)

Read from file.

Parameter Direction Type
size N/A uint32_t
buffer N/A void *
file in ATMO_FILESYSTEM_File_t *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_FileWrite(ATMO_DriverInstanceHandle_t instanceNumber, ATMO_FILESYSTEM_File_t *file, void *buffer, uint32_t size)

Write to file

Parameter Direction Type
size in uint32_t
buffer in void *
file in ATMO_FILESYSTEM_File_t *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_FileSeek(ATMO_DriverInstanceHandle_t instanceNumber, ATMO_FILESYSTEM_File_t *file, uint32_t offset)

Seek within a file.

Parameter Direction Type
offset in uint32_t
file in ATMO_FILESYSTEM_File_t *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_FileTell(ATMO_DriverInstanceHandle_t instanceNumber, ATMO_FILESYSTEM_File_t *file, uint32_t *currPos)

Get current position in file.

Parameter Direction Type
currPos out uint32_t *
file in ATMO_FILESYSTEM_File_t *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_FileSize(ATMO_DriverInstanceHandle_t instanceNumber, ATMO_FILESYSTEM_File_t *file, uint32_t *size)

Get file size.

Parameter Direction Type
size out uint32_t *
file in ATMO_FILESYSTEM_File_t *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_FileRewind(ATMO_DriverInstanceHandle_t instanceNumber, ATMO_FILESYSTEM_File_t *file)

Seek to beginning of file.

Parameter Direction Type
file in ATMO_FILESYSTEM_File_t *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_FileTruncate(ATMO_DriverInstanceHandle_t instanceNumber, ATMO_FILESYSTEM_File_t *file, uint32_t size)

Truncate file.

Parameter Direction Type
size in uint32_t
file in ATMO_FILESYSTEM_File_t *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t

ATMO_FILESYSTEM_Status_t ATMO_FILESYSTEM_DirMk(ATMO_DriverInstanceHandle_t instanceNumber, const char *path)

Make a new directory.

Parameter Direction Type
path in const char *
instanceNumber in ATMO_DriverInstanceHandle_t
Return Type
ATMO_FILESYSTEM_Status_t