CTS-SAT-1-OBC-Firmware
Loading...
Searching...
No Matches
littlefs_helper.h File Reference
#include <stdint.h>
#include "littlefs/flash_driver.h"
#include "littlefs/lfs.h"
Include dependency graph for littlefs_helper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LFS_MAX_PATH_LENGTH   250
 The maximum path length supported by CTS-SAT-1, including the null terminator.
 

Functions

int8_t LFS_format ()
 Formats Memory Module so it can successfully mount LittleFS.
 
int8_t LFS_mount ()
 Mounts LittleFS to the Memory Module.
 
int8_t LFS_unmount ()
 Unmounts LittleFS to the Memory Module.
 
int8_t LFS_ensure_mounted ()
 Mounts LFS filesystem if not already mounted. Does nothing if LFS is already mounted.
 
int8_t LFS_ensure_unmounted ()
 Mounts LFS filesystem if not already mounted. Does nothing if LFS is already mounted.
 
int8_t LFS_list_directory (const char root_directory[], uint16_t offset, int16_t count)
 Lists contents of LittleFS Directory, where each entry is sent as a log message.
 
int8_t LFS_make_directory (const char dir_name[])
 Creates directory.
 
int8_t LFS_delete_file (const char file_name[])
 Removes / deletes the file specified.
 
int8_t LFS_write_file (const char file_name[], uint8_t *write_buffer, uint32_t write_buffer_len)
 Creates/Opens LittleFS File to write to the Memory Module.
 
int8_t LFS_write_file_with_offset (const char file_name[], lfs_soff_t offset, uint8_t *write_buffer, uint32_t write_buffer_len)
 Creates / Opens LittleFS File and writes data at a specific offset.
 
int8_t LFS_append_file (const char file_name[], uint8_t *write_buffer, uint32_t write_buffer_len)
 Creates/Opens LittleFS File to append contents.
 
lfs_ssize_t LFS_read_file (const char file_name[], lfs_soff_t offset, uint8_t *read_buffer, uint32_t read_buffer_size)
 Opens LittleFS File to read from the Memory Module.
 
lfs_ssize_t LFS_file_size (const char file_name[])
 Returns the file size.
 

Variables

lfs_t LFS_filesystem
 
struct lfs_config LFS_cfg
 
struct lfs_file_config LFS_file_cfg
 
uint8_t LFS_is_lfs_mounted
 

Macro Definition Documentation

◆ LFS_MAX_PATH_LENGTH

#define LFS_MAX_PATH_LENGTH   250

The maximum path length supported by CTS-SAT-1, including the null terminator.

Note
LittleFS supports up to 255 bytes by default, but we'll restrict a bit under.

Function Documentation

◆ LFS_append_file()

int8_t LFS_append_file ( const char file_name[],
uint8_t * write_buffer,
uint32_t write_buffer_len )

Creates/Opens LittleFS File to append contents.

Parameters
file_name- Pointer to cstring holding the file name to create or open
write_buffer- Pointer to buffer holding the data to write
write_buffer_len- Size of the data to write
Returns
0 on success, 1 if LFS is unmounted, negative LFS error codes on failure
Here is the call graph for this function:

◆ LFS_delete_file()

int8_t LFS_delete_file ( const char file_name[])

Removes / deletes the file specified.

Parameters
file_namePointer to cstring holding the file name to remove
Returns
0 on success, 1 if LFS is unmounted, negative LFS error codes on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LFS_ensure_mounted()

int8_t LFS_ensure_mounted ( )

Mounts LFS filesystem if not already mounted. Does nothing if LFS is already mounted.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LFS_ensure_unmounted()

int8_t LFS_ensure_unmounted ( )

Mounts LFS filesystem if not already mounted. Does nothing if LFS is already mounted.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LFS_file_size()

lfs_ssize_t LFS_file_size ( const char file_name[])

Returns the file size.

Parameters
file_name- Pointer to buffer holding the file name to open
Returns
Returns negative values if read or file open failed, else the number of bytes in the file
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LFS_format()

int8_t LFS_format ( )

Formats Memory Module so it can successfully mount LittleFS.

Parameters
None
Returns
0 on success, 1 if LFS is already mounted, negative LFS error codes on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LFS_list_directory()

int8_t LFS_list_directory ( const char root_directory[],
uint16_t offset,
int16_t count )

Lists contents of LittleFS Directory, where each entry is sent as a log message.

Parameters
root_directorycstring holding the root directory to open and read
offsetNumber of entries to skip before listing directory
countNumber of entries to list in total (if 0, prints all entries)
Returns
0 on success, 1 if LFS is unmounted, negative LFS error codes on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LFS_make_directory()

int8_t LFS_make_directory ( const char dir_name[])

Creates directory.

Parameters
dir_namePointer to cstring holding the name of the directory
Returns
0 on success, 1 if LFS is unmounted, negative LFS error codes on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LFS_mount()

int8_t LFS_mount ( )

Mounts LittleFS to the Memory Module.

Parameters
None
Returns
0 on success, 1 if LFS is already mounted, negative LFS error codes on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LFS_read_file()

lfs_ssize_t LFS_read_file ( const char file_name[],
lfs_soff_t offset,
uint8_t * read_buffer,
uint32_t read_buffer_size )

Opens LittleFS File to read from the Memory Module.

Parameters
file_name- Pointer to buffer holding the file name to open
offset- position within the file to read from
read_buffer- Pointer to buffer where the read data will be stored
read_buffer_size- Size of the data to read
Returns
Returns negative values if read or file open failed, else the number of bytes read.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LFS_unmount()

int8_t LFS_unmount ( )

Unmounts LittleFS to the Memory Module.

Parameters
None
Returns
0 on success, 1 if LFS is already unmounted, negative LFS error codes on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LFS_write_file()

int8_t LFS_write_file ( const char file_name[],
uint8_t * write_buffer,
uint32_t write_buffer_len )

Creates/Opens LittleFS File to write to the Memory Module.

Parameters
file_name- Pointer to cstring holding the file name to create or open
write_buffer- Pointer to buffer holding the data to write
write_buffer_len- Size of the data to write
Returns
0 on success, 1 if LFS is unmounted, negative LFS error codes on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LFS_write_file_with_offset()

int8_t LFS_write_file_with_offset ( const char file_name[],
lfs_soff_t offset,
uint8_t * write_buffer,
uint32_t write_buffer_len )

Creates / Opens LittleFS File and writes data at a specific offset.

Parameters
file_name- Pointer to cstring holding the file name to create or open
offset- Position within the file to write the data
write_buffer- Pointer to buffer holding the data to write
write_buffer_len- Size of the data to write
Return values
0on success, 1 if LFS is unmounted, negative LFS error codes on failure
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ LFS_cfg

struct lfs_config LFS_cfg
extern

◆ LFS_file_cfg

struct lfs_file_config LFS_file_cfg
extern

◆ LFS_filesystem

lfs_t LFS_filesystem
extern

littlefs_helper.h

Created on: May 2, 2024 Author: Saksham Puri

◆ LFS_is_lfs_mounted

uint8_t LFS_is_lfs_mounted
extern