no-OS
Loading...
Searching...
No Matches
flash_storage.c File Reference
#include "flash_storage.h"
#include "afe_calibration.h"
#include "pqlib_example.h"
#include "afe_config.h"
#include "ade9430.h"
#include "flc.h"
#include "icc.h"
#include "mxc_device.h"
#include "mxc_delay.h"
#include <stdio.h>
#include <string.h>
Include dependency graph for flash_storage.c:

Macros

#define FLASH_CAL_PAGE_ADDR   ((MXC_FLASH_MEM_BASE + MXC_FLASH_MEM_SIZE) - (2 * MXC_FLASH_PAGE_SIZE))
 
#define FLASH_CAL_BACKUP_ADDR   ((MXC_FLASH_MEM_BASE + MXC_FLASH_MEM_SIZE) - (1 * MXC_FLASH_PAGE_SIZE))
 
#define CRC32_POLYNOMIAL   0xEDB88320
 

Functions

uint32_t flash_calculate_crc32 (const void *data, uint32_t len)
 Calculate CRC32 for data.
 
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.
 
bool flash_has_valid_calibration (void)
 Check if valid calibration data exists in 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.
 
const char * flash_status_to_string (FLASH_STATUS status)
 Get status string for flash status code.
 

Macro Definition Documentation

◆ CRC32_POLYNOMIAL

#define CRC32_POLYNOMIAL   0xEDB88320

◆ FLASH_CAL_BACKUP_ADDR

#define FLASH_CAL_BACKUP_ADDR   ((MXC_FLASH_MEM_BASE + MXC_FLASH_MEM_SIZE) - (1 * MXC_FLASH_PAGE_SIZE))

◆ FLASH_CAL_PAGE_ADDR

#define FLASH_CAL_PAGE_ADDR   ((MXC_FLASH_MEM_BASE + MXC_FLASH_MEM_SIZE) - (2 * MXC_FLASH_PAGE_SIZE))

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: