Speeduino
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
storage.cpp File Reference
#include "globals.h"
#include <EEPROM_LIB_H>
#include "storage.h"
#include "pages.h"
#include "table3d_axis_io.h"

Classes

struct  write_location
 

Macros

#define EEPROM_DATA_VERSION   0
 
#define STORAGE_END   0xFFF
 
#define EEPROM_CALIBRATION_CLT_VALUES   (STORAGE_END-sizeof(cltCalibration_values))
 
#define EEPROM_CALIBRATION_CLT_BINS   (EEPROM_CALIBRATION_CLT_VALUES-sizeof(cltCalibration_bins))
 
#define EEPROM_CALIBRATION_IAT_VALUES   (EEPROM_CALIBRATION_CLT_BINS-sizeof(iatCalibration_values))
 
#define EEPROM_CALIBRATION_IAT_BINS   (EEPROM_CALIBRATION_IAT_VALUES-sizeof(iatCalibration_bins))
 
#define EEPROM_CALIBRATION_O2_VALUES   (EEPROM_CALIBRATION_IAT_BINS-sizeof(o2Calibration_values))
 
#define EEPROM_CALIBRATION_O2_BINS   (EEPROM_CALIBRATION_O2_VALUES-sizeof(o2Calibration_bins))
 
#define EEPROM_LAST_BARO   (EEPROM_CALIBRATION_O2_BINS-1)
 

Functions

bool isEepromWritePending (void)
 
void writeAllConfig (void)
 
static write_location write_range (const byte *pStart, const byte *pEnd, write_location location)
 
static write_location write (const table_row_iterator &row, write_location location)
 
static write_location write (table_value_iterator it, write_location location)
 
static write_location write (table_axis_iterator it, write_location location)
 
static write_location writeTable (void *pTable, table_type_t key, write_location location)
 
void EEPROMWriteRaw (uint16_t address, uint8_t data)
 
uint8_t EEPROMReadRaw (uint16_t address)
 
void writeConfig (uint8_t pageNum)
 
void resetConfigPages (void)
 
static eeprom_address_t load_range (eeprom_address_t address, byte *pFirst, const byte *pLast)
 
static eeprom_address_t load (table_row_iterator row, eeprom_address_t address)
 
static eeprom_address_t load (table_value_iterator it, eeprom_address_t address)
 
static eeprom_address_t load (table_axis_iterator it, eeprom_address_t address)
 
static eeprom_address_t loadTable (void *pTable, table_type_t key, eeprom_address_t address)
 
void loadConfig (void)
 
void loadCalibration (void)
 
void writeCalibration (void)
 
void writeCalibrationPage (uint8_t pageNum)
 
static eeprom_address_t compute_crc_address (uint8_t pageNum)
 
void storePageCRC32 (uint8_t pageNum, uint32_t crcValue)
 
uint32_t readPageCRC32 (uint8_t pageNum)
 
void storeCalibrationCRC32 (uint8_t calibrationPageNum, uint32_t calibrationCRC)
 
uint32_t readCalibrationCRC32 (uint8_t calibrationPageNum)
 
uint16_t getEEPROMSize (void)
 
byte readLastBaro (void)
 Read last stored barometer reading from EEPROM.
 
void storeLastBaro (byte newValue)
 Write last acquired arometer reading to EEPROM.
 
byte readEEPROMVersion (void)
 Read EEPROM current data format version (from offset EEPROM_DATA_VERSION).
 
void storeEEPROMVersion (byte newVersion)
 Store EEPROM current data format version (to offset EEPROM_DATA_VERSION).
 

Variables

uint32_t deferEEPROMWritesUntil = 0
 

Detailed Description

Lower level ConfigPage*, Table2D, Table3D and EEPROM storage operations.

Macro Definition Documentation

◆ EEPROM_CALIBRATION_CLT_BINS

#define EEPROM_CALIBRATION_CLT_BINS   (EEPROM_CALIBRATION_CLT_VALUES-sizeof(cltCalibration_bins))

◆ EEPROM_CALIBRATION_CLT_VALUES

#define EEPROM_CALIBRATION_CLT_VALUES   (STORAGE_END-sizeof(cltCalibration_values))

◆ EEPROM_CALIBRATION_IAT_BINS

#define EEPROM_CALIBRATION_IAT_BINS   (EEPROM_CALIBRATION_IAT_VALUES-sizeof(iatCalibration_bins))

◆ EEPROM_CALIBRATION_IAT_VALUES

#define EEPROM_CALIBRATION_IAT_VALUES   (EEPROM_CALIBRATION_CLT_BINS-sizeof(iatCalibration_values))

◆ EEPROM_CALIBRATION_O2_BINS

#define EEPROM_CALIBRATION_O2_BINS   (EEPROM_CALIBRATION_O2_VALUES-sizeof(o2Calibration_bins))

◆ EEPROM_CALIBRATION_O2_VALUES

#define EEPROM_CALIBRATION_O2_VALUES   (EEPROM_CALIBRATION_IAT_BINS-sizeof(o2Calibration_values))

◆ EEPROM_DATA_VERSION

#define EEPROM_DATA_VERSION   0

◆ EEPROM_LAST_BARO

#define EEPROM_LAST_BARO   (EEPROM_CALIBRATION_O2_BINS-1)

◆ STORAGE_END

#define STORAGE_END   0xFFF

Function Documentation

◆ compute_crc_address()

static eeprom_address_t compute_crc_address ( uint8_t  pageNum)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EEPROMReadRaw()

uint8_t EEPROMReadRaw ( uint16_t  address)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EEPROMWriteRaw()

void EEPROMWriteRaw ( uint16_t  address,
uint8_t  data 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getEEPROMSize()

uint16_t getEEPROMSize ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEepromWritePending()

bool isEepromWritePending ( void  )
Here is the caller graph for this function:

◆ load() [1/3]

static eeprom_address_t load ( table_axis_iterator  it,
eeprom_address_t  address 
)
inlinestatic
Here is the call graph for this function:

◆ load() [2/3]

static eeprom_address_t load ( table_row_iterator  row,
eeprom_address_t  address 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load() [3/3]

static eeprom_address_t load ( table_value_iterator  it,
eeprom_address_t  address 
)
inlinestatic
Here is the call graph for this function:

◆ load_range()

static eeprom_address_t load_range ( eeprom_address_t  address,
byte pFirst,
const byte pLast 
)
inlinestatic

Load range of bytes form EEPROM offset to memory.

Parameters
address- start offset in EEPROM
pFirst- Start memory address
pLast- End memory address
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadCalibration()

void loadCalibration ( void  )

Read the calibration information from EEPROM. This is separate from the config load as the calibrations do not exist as pages within the ini file for Tuner Studio.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadConfig()

void loadConfig ( void  )

Load all config tables from storage.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadTable()

static eeprom_address_t loadTable ( void pTable,
table_type_t  key,
eeprom_address_t  address 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readCalibrationCRC32()

uint32_t readCalibrationCRC32 ( uint8_t  calibrationPageNum)

Retrieves and returns the 4 byte CRC32 checksum for a given calibration page from EEPROM.

Parameters
calibrationPageNum- Config page number
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readEEPROMVersion()

byte readEEPROMVersion ( void  )

Read EEPROM current data format version (from offset EEPROM_DATA_VERSION).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readLastBaro()

byte readLastBaro ( void  )

Read last stored barometer reading from EEPROM.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readPageCRC32()

uint32_t readPageCRC32 ( uint8_t  pageNum)

Retrieves and returns the 4 byte CRC32 checksum for a given page from EEPROM.

Parameters
pageNum- Config page number
Here is the call graph for this function:

◆ resetConfigPages()

void resetConfigPages ( void  )

Reset all configPage* structs (2,4,6,9,10,13) and write them full of null-bytes.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ storeCalibrationCRC32()

void storeCalibrationCRC32 ( uint8_t  calibrationPageNum,
uint32_t  calibrationCRC 
)

Same as above, but writes the CRC32 for the calibration page rather than tune data

Parameters
calibrationPageNum- Calibration page number
calibrationCRC- CRC32 checksum
Here is the call graph for this function:
Here is the caller graph for this function:

◆ storeEEPROMVersion()

void storeEEPROMVersion ( byte  newVersion)

Store EEPROM current data format version (to offset EEPROM_DATA_VERSION).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ storeLastBaro()

void storeLastBaro ( byte  newValue)

Write last acquired arometer reading to EEPROM.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ storePageCRC32()

void storePageCRC32 ( uint8_t  pageNum,
uint32_t  crcValue 
)

Write CRC32 checksum to EEPROM. Takes a page number and CRC32 value then stores it in the relevant place in EEPROM

Parameters
pageNum- Config page number
crcValue- CRC32 checksum
Here is the call graph for this function:

◆ write() [1/3]

static write_location write ( const table_row_iterator row,
write_location  location 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write() [2/3]

static write_location write ( table_axis_iterator  it,
write_location  location 
)
inlinestatic
Here is the call graph for this function:

◆ write() [3/3]

static write_location write ( table_value_iterator  it,
write_location  location 
)
inlinestatic
Here is the call graph for this function:

◆ write_range()

static write_location write_range ( const byte pStart,
const byte pEnd,
write_location  location 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeAllConfig()

void writeAllConfig ( void  )

Write all config pages to EEPROM.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeCalibration()

void writeCalibration ( void  )

Write calibration tables to EEPROM. This takes the values in the 3 calibration tables (Coolant, Inlet temp and O2) and saves them to the EEPROM.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeCalibrationPage()

void writeCalibrationPage ( uint8_t  pageNum)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeConfig()

void writeConfig ( uint8_t  pageNum)

Write a table or map to EEPROM storage. Takes the current configuration (config pages and maps) and writes them to EEPROM as per the layout defined in storage.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeTable()

static write_location writeTable ( void pTable,
table_type_t  key,
write_location  location 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ deferEEPROMWritesUntil

uint32_t deferEEPROMWritesUntil = 0