CTS-SAT-1-OBC-Firmware
|
#include <stdint.h>
#include "littlefs/littlefs_helper.h"
#include "littlefs/lfs.h"
#include "littlefs/littlefs_driver.h"
#include "log/log.h"
Macros | |
#define | FLASH_CHIP_PAGE_SIZE_BYTES 2048 |
#define | FLASH_CHIP_BLOCK_SIZE_BYTES FLASH_CHIP_PAGE_SIZE_BYTES * FLASH_CHIP_PAGES_PER_BLOCK |
#define | FLASH_LOOKAHEAD_SIZE 16 |
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_append_file (const char file_name[], uint8_t *write_buffer, uint32_t write_buffer_len) |
Creates/Opens LittleFS File to append contents. | |
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. | |
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 | |
uint8_t | LFS_is_lfs_mounted = 0 |
uint8_t | LFS_read_buffer [FLASH_CHIP_PAGE_SIZE_BYTES] |
uint8_t | LFS_prog_buffer [FLASH_CHIP_PAGE_SIZE_BYTES] |
uint8_t | LFS_lookahead_buf [FLASH_LOOKAHEAD_SIZE] |
uint8_t | LFS_file_buffer [FLASH_CHIP_PAGE_SIZE_BYTES] |
lfs_t | LFS_filesystem |
struct lfs_config | LFS_cfg |
struct lfs_file_config | LFS_file_cfg |
#define FLASH_CHIP_BLOCK_SIZE_BYTES FLASH_CHIP_PAGE_SIZE_BYTES * FLASH_CHIP_PAGES_PER_BLOCK |
#define FLASH_CHIP_PAGE_SIZE_BYTES 2048 |
#define FLASH_LOOKAHEAD_SIZE 16 |
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.
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 |
int8_t LFS_delete_file | ( | const char | file_name[] | ) |
Removes / deletes the file specified.
file_name | Pointer to cstring holding the file name to remove |
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.
lfs_ssize_t LFS_file_size | ( | const char | file_name[] | ) |
Returns the file size.
file_name | - Pointer to buffer holding the file name to open |
int8_t LFS_format | ( | ) |
Formats Memory Module so it can successfully mount LittleFS.
None |
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.
root_directory | cstring holding the root directory to open and read |
offset | Number of entries to skip before listing directory |
count | Number of entries to list in total (if 0, prints all entries) |
int8_t LFS_make_directory | ( | const char | dir_name[] | ) |
Creates directory.
dir_name | Pointer to cstring holding the name of the directory |
int8_t LFS_mount | ( | ) |
Mounts LittleFS to the Memory Module.
None |
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.
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 |
int8_t LFS_unmount | ( | ) |
Unmounts LittleFS to the Memory Module.
None |
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.
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 |
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.
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 |
0 | on success, 1 if LFS is unmounted, negative LFS error codes on failure |
struct lfs_config LFS_cfg |
uint8_t LFS_file_buffer[FLASH_CHIP_PAGE_SIZE_BYTES] |
struct lfs_file_config LFS_file_cfg |
lfs_t LFS_filesystem |
Created on: May 2, 2024 Author: Saksham Puri
uint8_t LFS_is_lfs_mounted = 0 |
uint8_t LFS_lookahead_buf[FLASH_LOOKAHEAD_SIZE] |
uint8_t LFS_prog_buffer[FLASH_CHIP_PAGE_SIZE_BYTES] |
uint8_t LFS_read_buffer[FLASH_CHIP_PAGE_SIZE_BYTES] |