no-OS
Loading...
Searching...
No Matches
flash_storage.h File Reference
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for flash_storage.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  FLASH_CHANNEL_CALIBRATION
 Calibration coefficients for a single channel (phase) More...
 
struct  FLASH_CALIBRATION_DATA
 Complete calibration data structure. More...
 

Macros

#define FLASH_SECTOR_SIZE   0x1000
 
#define FLASH_MAGIC_CALIBRATION   0x43414C49 /* "CALI" */
 
#define FLASH_VERSION_CALIBRATION   0x0001
 
#define FLASH_NUM_CHANNELS   3
 

Enumerations

enum  FLASH_STATUS {
  FLASH_STATUS_OK = 0 ,
  FLASH_STATUS_NO_DATA = -9 ,
  FLASH_STATUS_INVALID_CRC ,
  FLASH_STATUS_INVALID_VERSION ,
  FLASH_STATUS_INVALID_MAGIC ,
  FLASH_STATUS_ERASE_FAILED ,
  FLASH_STATUS_WRITE_FAILED ,
  FLASH_STATUS_READ_FAILED ,
  FLASH_STATUS_INIT_FAILED ,
  FLASH_STATUS_NOT_INITIALIZED
}
 Flash storage status. More...
 

Functions

int flash_storage_init (void)
 Initialize flash storage.
 
int flash_storage_remove (void)
 De-initialize flash storage.
 
bool flash_storage_is_initialized (void)
 Check if flash storage is initialized.
 
int flash_read_calibration (FLASH_CALIBRATION_DATA *data)
 Read calibration data from flash.
 
int flash_write_calibration (const FLASH_CALIBRATION_DATA *data)
 Write calibration data to flash.
 
int flash_erase_calibration (void)
 Erase calibration data from flash.
 
int flash_load_and_apply_calibration (void)
 Load calibration from flash and apply to AFE registers.
 
int flash_save_calibration_channel (uint8_t channel)
 Save current calibration context to flash for specified channel.
 
int flash_save_all_calibration (void)
 Save all calibration data to flash.
 
bool flash_has_valid_calibration (void)
 Check if valid calibration data exists in flash.
 
const char * flash_status_to_string (FLASH_STATUS status)
 Get status string for flash status code.
 
uint32_t flash_calculate_crc32 (const void *data, uint32_t len)
 Calculate CRC32 for data.
 

Macro Definition Documentation

◆ FLASH_MAGIC_CALIBRATION

#define FLASH_MAGIC_CALIBRATION   0x43414C49 /* "CALI" */

◆ FLASH_NUM_CHANNELS

#define FLASH_NUM_CHANNELS   3

◆ FLASH_SECTOR_SIZE

#define FLASH_SECTOR_SIZE   0x1000

◆ FLASH_VERSION_CALIBRATION

#define FLASH_VERSION_CALIBRATION   0x0001

Enumeration Type Documentation

◆ FLASH_STATUS

Flash storage status.

Enumerator
FLASH_STATUS_OK 
FLASH_STATUS_NO_DATA 
FLASH_STATUS_INVALID_CRC 
FLASH_STATUS_INVALID_VERSION 
FLASH_STATUS_INVALID_MAGIC 
FLASH_STATUS_ERASE_FAILED 
FLASH_STATUS_WRITE_FAILED 
FLASH_STATUS_READ_FAILED 
FLASH_STATUS_INIT_FAILED 
FLASH_STATUS_NOT_INITIALIZED 

Function Documentation

◆ flash_calculate_crc32()

uint32_t flash_calculate_crc32 ( const void * data,
uint32_t len )

Calculate CRC32 for data.

Parameters
data- Pointer to data
len- Length of data in bytes
Returns
CRC32 value
Here is the caller graph for this function:

◆ flash_erase_calibration()

int flash_erase_calibration ( void )

Erase calibration data from flash.

Returns
FLASH_STATUS_OK on success, error code otherwise
Here is the caller graph for this function:

◆ flash_has_valid_calibration()

bool flash_has_valid_calibration ( void )

Check if valid calibration data exists in flash.

Returns
true if valid data exists, false otherwise
Here is the caller graph for this function:

◆ flash_load_and_apply_calibration()

int flash_load_and_apply_calibration ( void )

Load calibration from flash and apply to AFE registers.

Returns
FLASH_STATUS_OK on success, error code otherwise
Here is the caller graph for this function:

◆ flash_read_calibration()

int flash_read_calibration ( FLASH_CALIBRATION_DATA * data)

Read calibration data from flash.

Parameters
data- Pointer to calibration data structure
Returns
FLASH_STATUS_OK on success, error code otherwise
Here is the caller graph for this function:

◆ flash_save_all_calibration()

int flash_save_all_calibration ( void )

Save all calibration data to flash.

Returns
FLASH_STATUS_OK on success, error code otherwise

◆ flash_save_calibration_channel()

int flash_save_calibration_channel ( uint8_t channel)

Save current calibration context to flash for specified channel.

Parameters
channel- Channel to save (0=A, 1=B, 2=C)
Returns
FLASH_STATUS_OK on success, error code otherwise
Here is the caller graph for this function:

◆ flash_status_to_string()

const char * flash_status_to_string ( FLASH_STATUS status)

Get status string for flash status code.

Parameters
status- Flash status code
Returns
Status string

◆ flash_storage_init()

int flash_storage_init ( void )

Initialize flash storage.

Returns
FLASH_STATUS_OK on success, error code otherwise
Here is the caller graph for this function:

◆ flash_storage_is_initialized()

bool flash_storage_is_initialized ( void )

Check if flash storage is initialized.

Returns
true if initialized, false otherwise
Here is the caller graph for this function:

◆ flash_storage_remove()

int flash_storage_remove ( void )

De-initialize flash storage.

Returns
FLASH_STATUS_OK on success, error code otherwise

◆ flash_write_calibration()

int flash_write_calibration ( const FLASH_CALIBRATION_DATA * data)

Write calibration data to flash.

Parameters
data- Pointer to calibration data structure
Returns
FLASH_STATUS_OK on success, error code otherwise
Here is the caller graph for this function: