ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_interface_flash.h File Reference

Interface functions to persistent flash storage. More...

#include "ruuvi_driver_enabled_modules.h"
#include "ruuvi_driver_error.h"
#include <stddef.h>

Go to the source code of this file.

Macros

#define RI_FLASH_PAGES   (10U)
 Enable implementation selected by application. More...
 

Functions

rd_status_t ri_flash_total_size_get (size_t *size)
 Get total size of usable flash, excluding any overhead bytes. More...
 
rd_status_t ri_flash_page_size_get (size_t *size)
 Get size of usable page, excluding any overhead bytes If returned value is N, a record of N bytes must fit in one page. More...
 
rd_status_t ri_flash_free_size_get (size_t *size)
 Get total size of free flash. More...
 
rd_status_t ri_flash_record_delete (const uint32_t file_id, const uint32_t record_id)
 Mark a record for deletion. More...
 
rd_status_t ri_flash_record_set (const uint32_t page_id, const uint32_t record_id, const size_t data_size, const void *const data)
 Set data to record in page. More...
 
rd_status_t ri_flash_record_get (const uint32_t page_id, const uint32_t record_id, const size_t data_size, void *const data)
 Get data from record in page. More...
 
rd_status_t ri_flash_gc_run (void)
 Run garbage collection. More...
 
rd_status_t ri_flash_init (void)
 
rd_status_t ri_flash_uninit (void)
 Unintialize flash. After uninitialization only initialization can be used. More...
 
void ri_flash_purge (void)
 Purge flash. More...
 
bool ri_flash_is_busy ()
 Check if flash is busy. More...
 
rd_status_t ri_flash_protect (const size_t page)
 

Detailed Description

Interface functions to persistent flash storage.

Author
Otso Jousimaa otso@.nosp@m.ojou.nosp@m.sima..nosp@m.net
Date
2020-12-10

Flash is stored to pages which are ideally of same size as the underlying physical write/erase unit. Each page may contain N records. Underlying driver is allowed to arrange pages and records in any manner to implement wear leveling. Underlying driver is allowed to trigger garbage collection on write, which makes runtime of operation undeterministic.

Definition in file ruuvi_interface_flash.h.