Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
SpiSPIFFS Class Reference
Inheritance diagram for SpiSPIFFS:
SPIFFS FileSystem Atomic FileIO

Public Member Functions

 SpiSPIFFS (SPIFlash *flash, size_t physical_address, size_t size_on_disk, size_t logical_block_size, size_t logical_page_size, size_t max_num_open_descriptors=16, size_t cache_pages=8, std::function< void()> post_format_hook=nullptr)
 Constructor.
 
 ~SpiSPIFFS ()
 Destructor.
 
- Public Member Functions inherited from SPIFFS
void mount (const char *mount_point) override
 Mount the file system.
 
void format () override
 Format the file system, all data will be lost.
 
bool is_any_dirty ()
 
void flush_cache ()
 Performs a sync on all files that have had a write but no fsync call since then.
 
- Public Member Functions inherited from FileSystem
 FileSystem ()
 Constructor.
 
virtual ~FileSystem ()
 Destructor.
 

Private Member Functions

int32_t flash_read (uint32_t addr, uint32_t size, uint8_t *dst) override
 SPIFFS callback to read flash, in context.
 
int32_t flash_write (uint32_t addr, uint32_t size, uint8_t *src) override
 SPIFFS callback to write flash, in context.
 
int32_t flash_erase (uint32_t addr, uint32_t size) override
 SPIFFS callback to erase flash, in context.
 
 DISALLOW_COPY_AND_ASSIGN (SpiSPIFFS)
 

Private Attributes

SPIFlashflash_
 Flash access helper.
 

Additional Inherited Members

- Static Public Member Functions inherited from SPIFFS
static void extern_lock (struct spiffs_t *fs)
 Provide mutex lock.
 
static void extern_unlock (struct spiffs_t *fs)
 Provide mutex unlock.
 
- Static Public Member Functions inherited from FileSystem
static int open (struct _reent *reent, const char *path, int flags, int mode)
 Open a file or device.
 
static int close (struct _reent *reent, int fd)
 Close a file or device.
 
static int unlink (struct _reent *reent, const char *path)
 Remove a file.
 
static int stat (struct _reent *reent, const char *path, struct stat *stat)
 Get the status information of a file or device.
 
static int fsync (int fd)
 Synchronize (flush) a file to disk.
 
static int closedir (DIR *dirp)
 Close a directory.
 
static DIRopendir (const char *name)
 Open a directory.
 
static struct direntreaddir (DIR *dirp)
 Read the next entry in a directory.
 
- Static Public Member Functions inherited from FileIO
static ssize_t read (struct _reent *reent, int fd, void *buf, size_t count)
 Read from a file or device.
 
static ssize_t write (struct _reent *reent, int fd, const void *buf, size_t count)
 Write to a file or device.
 
static _off_t lseek (struct _reent *reent, int fd, _off_t offset, int whence)
 Change the offset index of a file or device.
 
static int fstat (struct _reent *reent, int fd, struct stat *stat)
 Get the status information of a file or device.
 
static int ioctl (int fd, unsigned long int key, unsigned long data)
 Request and ioctl transaction.
 
static int fcntl (int fd, int cmd, unsigned long data)
 Manipulate a file descriptor.
 
static bool is_device (int fd)
 Test if the file descriptor belongs to a device.
 
- Protected Member Functions inherited from SPIFFS
 SPIFFS (size_t physical_address, size_t size_on_disk, size_t erase_block_size, size_t logical_block_size, size_t logical_page_size, size_t max_num_open_descriptors=16, size_t cache_pages=8, std::function< void()> post_format_hook=nullptr)
 Constructor.
 
 ~SPIFFS ()
 Destructor.
 
void unmount ()
 Flushes caches and unmounts the filesystem.
 
- Protected Member Functions inherited from FileIO
 FileIO (const char *name)
 Constructor.
 
virtual ~FileIO ()
 Destructor.
 
virtual int ioctl (File *file, unsigned long int key, unsigned long data)
 Request an ioctl transaction.
 
virtual int fcntl (File *file, int cmd, unsigned long data)
 Manipulate a file descriptor.
 
virtual bool select (File *file, int mode)
 Device select method.
 
- Static Protected Member Functions inherited from SPIFFS
static int flash_read (struct spiffs_t *fs, unsigned addr, unsigned size, uint8_t *dst)
 SPIFFS callback to read flash.
 
static int flash_write (struct spiffs_t *fs, unsigned addr, unsigned size, uint8_t *src)
 SPIFFS callback to write flash.
 
static int flash_erase (struct spiffs_t *fs, unsigned addr, unsigned size)
 SPIFFS callback to erase flash.
 
- Static Protected Member Functions inherited from FileIO
static int fd_alloc (void)
 Allocate a free file descriptor.
 
static void fd_free (int fd)
 Free up a file descriptor.
 
static Filefile_lookup (int fd)
 Looks up a reference to a File corresponding to a given file descriptor.
 
static int fd_lookup (File *file)
 Looks up a file descriptor corresponding to a given File reference.
 
- Protected Attributes inherited from SPIFFS
spiffs * fs_
 file system instance metadata
 
- Protected Attributes inherited from FileIO
const char * name
 device name
 
- Static Protected Attributes inherited from FileIO
static const unsigned int numOpenFiles = 20
 
static File files []
 File descriptor pool.
 
static OSMutex mutex
 mutual exclusion for fileio
 

Detailed Description

Definition at line 43 of file SpiSPIFFS.hxx.

Constructor & Destructor Documentation

◆ SpiSPIFFS()

SpiSPIFFS::SpiSPIFFS ( SPIFlash flash,
size_t  physical_address,
size_t  size_on_disk,
size_t  logical_block_size,
size_t  logical_page_size,
size_t  max_num_open_descriptors = 16,
size_t  cache_pages = 8,
std::function< void()>  post_format_hook = nullptr 
)

Constructor.

Parameters
flashis the spi flash driver. This must be initialized before calling any operation (such as mount) on this file system. This object must stay alive as long as the filesystem is in use (ownership is not transferred).
physical_addressaddress relative to the beginning of the flash device.
size_on_diskhow long the filesystem is
logical_block_sizesee SPIFFS documentation
logical_page_sizesee SPIFFS documentation
max_num_open_descriptorshow many fds should we allocate memory for
cache_pageshow many pages SPIFFS should store in RAM
post_format_hookmethod to be called after a clean format of the file system. This allows the user to prime a clean or factory reset file system with an initial set files.

Definition at line 41 of file SpiSPIFFS.cxx.

◆ ~SpiSPIFFS()

SpiSPIFFS::~SpiSPIFFS ( )

Destructor.

Definition at line 52 of file SpiSPIFFS.cxx.

Member Function Documentation

◆ flash_erase()

int32_t SpiSPIFFS::flash_erase ( uint32_t  addr,
uint32_t  size 
)
overrideprivatevirtual

SPIFFS callback to erase flash, in context.

Parameters
addradddress location to erase
sizesize of erase region in bytes

Implements SPIFFS.

Definition at line 76 of file SpiSPIFFS.cxx.

◆ flash_read()

int32_t SpiSPIFFS::flash_read ( uint32_t  addr,
uint32_t  size,
uint8_t *  dst 
)
overrideprivatevirtual

SPIFFS callback to read flash, in context.

Parameters
addradddress location to read
sizesize of read in bytes
dstdestination buffer for read

Implements SPIFFS.

Definition at line 57 of file SpiSPIFFS.cxx.

◆ flash_write()

int32_t SpiSPIFFS::flash_write ( uint32_t  addr,
uint32_t  size,
uint8_t *  src 
)
overrideprivatevirtual

SPIFFS callback to write flash, in context.

Parameters
addradddress location to write
sizesize of write in bytes
srcsource buffer for write

Implements SPIFFS.

Definition at line 63 of file SpiSPIFFS.cxx.

Member Data Documentation

◆ flash_

SPIFlash* SpiSPIFFS::flash_
private

Flash access helper.

Definition at line 89 of file SpiSPIFFS.hxx.


The documentation for this class was generated from the following files: