Speeduino
Loading...
Searching...
No Matches
Macros | Functions | Variables
storage.h File Reference

Functions for reading and writing user settings to/from EEPROM. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EEPROM_CONFIG1_MAP   3
 
#define EEPROM_CONFIG2_START   291
 
#define EEPROM_CONFIG2_END   419
 
#define EEPROM_CONFIG3_MAP   421
 
#define EEPROM_CONFIG4_START   709
 
#define EEPROM_CONFIG4_END   837
 
#define EEPROM_CONFIG5_MAP   839
 
#define EEPROM_CONFIG6_START   1127
 
#define EEPROM_CONFIG6_END   1255
 
#define EEPROM_CONFIG7_MAP1   1257
 
#define EEPROM_CONFIG7_MAP2   1339
 
#define EEPROM_CONFIG7_MAP3   1421
 
#define EEPROM_CONFIG7_END   1501
 
#define EEPROM_CONFIG8_MAP1   1503
 
#define EEPROM_CONFIG8_MAP2   1553
 
#define EEPROM_CONFIG8_MAP3   1603
 
#define EEPROM_CONFIG8_MAP4   1653
 
#define EEPROM_CONFIG9_START   1710
 
#define EEPROM_CONFIG9_END   1902
 
#define EEPROM_CONFIG10_START   1902
 
#define EEPROM_CONFIG10_END   2094
 
#define EEPROM_CONFIG11_MAP   2096
 
#define EEPROM_CONFIG11_END   2385
 
#define EEPROM_CONFIG12_MAP   2387
 
#define EEPROM_CONFIG12_MAP2   2469
 
#define EEPROM_CONFIG12_MAP3   2551
 
#define EEPROM_CONFIG12_END   2575
 
#define EEPROM_CONFIG13_START   2580
 
#define EEPROM_CONFIG13_END   2708
 
#define EEPROM_CONFIG14_MAP   2710
 
#define EEPROM_CONFIG14_END   2998
 
#define EEPROM_CONFIG8_MAP5   3001
 
#define EEPROM_CONFIG8_MAP6   3051
 
#define EEPROM_CONFIG8_MAP7   3101
 
#define EEPROM_CONFIG8_MAP8   3151
 
#define EEPROM_CONFIG15_MAP   3199
 
#define EEPROM_CONFIG15_START   3281
 
#define EEPROM_CONFIG15_END   3457
 
#define EEPROM_CALIBRATION_CLT_CRC   3674
 
#define EEPROM_CALIBRATION_IAT_CRC   3678
 
#define EEPROM_CALIBRATION_O2_CRC   3682
 
#define EEPROM_CALIBRATION_O2_OLD   2559
 
#define EEPROM_CALIBRATION_IAT_OLD   3071
 
#define EEPROM_CALIBRATION_CLT_OLD   3583
 
#define EEPROM_DEFER_DELAY   MICROS_PER_SEC
 

Functions

void writeAllConfig (void)
 
void writeConfig (uint8_t pageNum)
 
void EEPROMWriteRaw (uint16_t address, uint8_t data)
 
uint8_t EEPROMReadRaw (uint16_t address)
 
void loadConfig (void)
 
void loadCalibration (void)
 
void writeCalibration (void)
 
void writeCalibrationPage (uint8_t pageNum)
 
void resetConfigPages (void)
 
byte readLastBaro (void)
 Read last stored barometer reading from EEPROM.
 
void storeLastBaro (byte newValue)
 Write last acquired arometer reading to EEPROM.
 
uint8_t 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).
 
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)
 
bool isEepromWritePending (void)
 

Variables

uint32_t deferEEPROMWritesUntil
 

Detailed Description

Functions for reading and writing user settings to/from EEPROM.

Current layout of EEPROM is as follows (Version 18):

Offset (Dec) Size (Bytes) Description Reference
0 1 EEPROM version EEPROM_DATA_VERSION
1 2 X and Y sizes for fuel table
3 256 Fuel table (16x16) EEPROM_CONFIG1_MAP
259 16 Fuel table (X axis) (RPM)
275 16 Fuel table (Y axis) (MAP/TPS)
291 128 Page 2 settings EEPROM_CONFIG2_START
419 2 X and Y sizes for ignition table
421 256 Ignition table (16x16) EEPROM_CONFIG3_MAP
677 16 Ignition table (X axis) (RPM)
693 16 Ignition table (Y axis) (MAP/TPS)
709 128 Page 4 settings EEPROM_CONFIG4_START
837 2 X and Y sizes for AFR target table
839 256 AFR target table (16x16) EEPROM_CONFIG5_MAP
1095 16 AFR target table (X axis) (RPM)
1111 16 AFR target table (Y axis) (MAP/TPS)
1127 128 Page 6 settings EEPROM_CONFIG6_START
1255 2 X and Y sizes for boost table
1257 64 Boost table (8x8) EEPROM_CONFIG7_MAP1
1321 8 Boost table (X axis) (RPM)
1329 8 Boost table (Y axis) (TPS)
1337 2 X and Y sizes for vvt table
1339 64 VVT table (8x8) EEPROM_CONFIG7_MAP2
1403 8 VVT table (X axis) (RPM)
1411 8 VVT table (Y axis) (MAP)
1419 2 X and Y sizes for staging table
1421 64 Staging table (8x8) EEPROM_CONFIG7_MAP3
1485 8 Staging table (X axis) (RPM)
1493 8 Staging table (Y axis) (MAP)
1501 2 X and Y sizes for trim1 table
1503 36 Trim1 table (6x6) EEPROM_CONFIG8_MAP1
1539 6 Trim1 table (X axis) (RPM)
1545 6 Trim1 table (Y axis) (MAP)
1551 2 X and Y sizes for trim2 table
1553 36 Trim2 table (6x6) EEPROM_CONFIG8_MAP2
1589 6 Trim2 table (X axis) (RPM)
1595 6 Trim2 table (Y axis) (MAP)
1601 2 X and Y sizes for trim3 table
1603 36 Trim3 table (6x6) EEPROM_CONFIG8_MAP3
1639 6 Trim3 table (X axis) (RPM)
1545 6 Trim3 table (Y axis) (MAP)
1651 2 X and Y sizes for trim4 table
1653 36 Trim4 table (6x6) EEPROM_CONFIG8_MAP4
1689 6 Trim4 table (X axis) (RPM)
1595 6 Trim4 table (Y axis) (MAP)
1701 9 HOLE ??
1710 192 Page 9 settings EEPROM_CONFIG9_START
1902 192 Page 10 settings EEPROM_CONFIG10_START
2094 2 X and Y sizes for fuel2 table
2096 256 Fuel2 table (16x16) EEPROM_CONFIG11_MAP
2352 16 Fuel2 table (X axis) (RPM)
2368 16 Fuel2 table (Y axis) (MAP/TPS)
2384 1 HOLE ??
2385 2 X and Y sizes for WMI table
2387 64 WMI table (8x8) EEPROM_CONFIG12_MAP
2451 8 WMI table (X axis) (RPM)
2459 8 WMI table (Y axis) (MAP)
2467 2 X and Y sizes VVT2 table
2469 64 VVT2 table (8x8) EEPROM_CONFIG12_MAP2
2553 8 VVT2 table (X axis) (RPM)
2541 8 VVT2 table (Y axis) (MAP)
2549 2 X and Y sizes dwell table
2551 16 Dwell table (4x4) EEPROM_CONFIG12_MAP3
2567 4 Dwell table (X axis) (RPM)
2571 4 Dwell table (Y axis) (MAP)
2575 5 HOLE ??
2580 128 Page 13 settings EEPROM_CONFIG13_START
2708 2 X and Y sizes for ignition2 table
2710 256 Ignition2 table (16x16) EEPROM_CONFIG14_MAP
2966 16 Ignition2 table (X axis) (RPM)
2982 16 Ignition2 table (Y axis) (MAP/TPS)
2998 1 HOLE ??
2999 2 X and Y sizes for trim5 table
3001 36 Trim5 table (6x6) EEPROM_CONFIG8_MAP5
3037 6 Trim5 table (X axis) (RPM)
3043 6 Trim5 table (Y axis) (MAP)
3049 2 X and Y sizes for trim6 table
3051 36 Trim6 table (6x6) EEPROM_CONFIG8_MAP6
3087 6 Trim6 table (X axis) (RPM)
3093 6 Trim6 table (Y axis) (MAP)
3099 2 X and Y sizes for trim7 table
3101 36 Trim7 table (6x6) EEPROM_CONFIG8_MAP7
3137 6 Trim7 table (X axis) (RPM)
3143 6 Trim7 table (Y axis) (MAP)
3149 2 X and Y sizes for trim8 table
3151 36 Trim8 table (6x6) EEPROM_CONFIG8_MAP8
3187 6 Trim8 table (X axis) (RPM)
3193 6 Trim8 table (Y axis) (MAP)
3199 2 X and Y sizes boostLUT table
3201 64 boostLUT table (8x8) EEPROM_CONFIG15_MAP
3265 8 boostLUT table (X axis) (RPM)
3273 8 boostLUT table (Y axis) (targetBoost)
3281 1 boostLUT enable EEPROM_CONFIG15_START
3282 1 boostDCWhenDisabled
3283 1 boostControlEnableThreshold
3284 14 A/C Control Settings
3298 159 Page 15 spare
3457 217 EMPTY
3674 4 CLT Calibration CRC32
3678 4 IAT Calibration CRC32
3682 4 O2 Calibration CRC32
3686 56 Page CRC32 sums (4x14) Last first, 14 -> 1
3742 1 Baro value saved at init EEPROM_LAST_BARO
3743 64 O2 Calibration Bins EEPROM_CALIBRATION_O2_BINS
3807 32 O2 Calibration Values EEPROM_CALIBRATION_O2_VALUES
3839 64 IAT Calibration Bins EEPROM_CALIBRATION_IAT_BINS
3903 64 IAT Calibration Values EEPROM_CALIBRATION_IAT_VALUES
3967 64 CLT Calibration Bins EEPROM_CALIBRATION_CLT_BINS
4031 64 CLT Calibration Values EEPROM_CALIBRATION_CLT_VALUES
4095 END

Macro Definition Documentation

◆ EEPROM_CALIBRATION_CLT_CRC

#define EEPROM_CALIBRATION_CLT_CRC   3674

◆ EEPROM_CALIBRATION_CLT_OLD

#define EEPROM_CALIBRATION_CLT_OLD   3583

◆ EEPROM_CALIBRATION_IAT_CRC

#define EEPROM_CALIBRATION_IAT_CRC   3678

◆ EEPROM_CALIBRATION_IAT_OLD

#define EEPROM_CALIBRATION_IAT_OLD   3071

◆ EEPROM_CALIBRATION_O2_CRC

#define EEPROM_CALIBRATION_O2_CRC   3682

◆ EEPROM_CALIBRATION_O2_OLD

#define EEPROM_CALIBRATION_O2_OLD   2559

◆ EEPROM_CONFIG10_END

#define EEPROM_CONFIG10_END   2094

◆ EEPROM_CONFIG10_START

#define EEPROM_CONFIG10_START   1902

◆ EEPROM_CONFIG11_END

#define EEPROM_CONFIG11_END   2385

◆ EEPROM_CONFIG11_MAP

#define EEPROM_CONFIG11_MAP   2096

◆ EEPROM_CONFIG12_END

#define EEPROM_CONFIG12_END   2575

◆ EEPROM_CONFIG12_MAP

#define EEPROM_CONFIG12_MAP   2387

◆ EEPROM_CONFIG12_MAP2

#define EEPROM_CONFIG12_MAP2   2469

◆ EEPROM_CONFIG12_MAP3

#define EEPROM_CONFIG12_MAP3   2551

◆ EEPROM_CONFIG13_END

#define EEPROM_CONFIG13_END   2708

◆ EEPROM_CONFIG13_START

#define EEPROM_CONFIG13_START   2580

◆ EEPROM_CONFIG14_END

#define EEPROM_CONFIG14_END   2998

◆ EEPROM_CONFIG14_MAP

#define EEPROM_CONFIG14_MAP   2710

◆ EEPROM_CONFIG15_END

#define EEPROM_CONFIG15_END   3457

◆ EEPROM_CONFIG15_MAP

#define EEPROM_CONFIG15_MAP   3199

◆ EEPROM_CONFIG15_START

#define EEPROM_CONFIG15_START   3281

◆ EEPROM_CONFIG1_MAP

#define EEPROM_CONFIG1_MAP   3

◆ EEPROM_CONFIG2_END

#define EEPROM_CONFIG2_END   419

◆ EEPROM_CONFIG2_START

#define EEPROM_CONFIG2_START   291

◆ EEPROM_CONFIG3_MAP

#define EEPROM_CONFIG3_MAP   421

◆ EEPROM_CONFIG4_END

#define EEPROM_CONFIG4_END   837

◆ EEPROM_CONFIG4_START

#define EEPROM_CONFIG4_START   709

◆ EEPROM_CONFIG5_MAP

#define EEPROM_CONFIG5_MAP   839

◆ EEPROM_CONFIG6_END

#define EEPROM_CONFIG6_END   1255

◆ EEPROM_CONFIG6_START

#define EEPROM_CONFIG6_START   1127

◆ EEPROM_CONFIG7_END

#define EEPROM_CONFIG7_END   1501

◆ EEPROM_CONFIG7_MAP1

#define EEPROM_CONFIG7_MAP1   1257

◆ EEPROM_CONFIG7_MAP2

#define EEPROM_CONFIG7_MAP2   1339

◆ EEPROM_CONFIG7_MAP3

#define EEPROM_CONFIG7_MAP3   1421

◆ EEPROM_CONFIG8_MAP1

#define EEPROM_CONFIG8_MAP1   1503

◆ EEPROM_CONFIG8_MAP2

#define EEPROM_CONFIG8_MAP2   1553

◆ EEPROM_CONFIG8_MAP3

#define EEPROM_CONFIG8_MAP3   1603

◆ EEPROM_CONFIG8_MAP4

#define EEPROM_CONFIG8_MAP4   1653

◆ EEPROM_CONFIG8_MAP5

#define EEPROM_CONFIG8_MAP5   3001

◆ EEPROM_CONFIG8_MAP6

#define EEPROM_CONFIG8_MAP6   3051

◆ EEPROM_CONFIG8_MAP7

#define EEPROM_CONFIG8_MAP7   3101

◆ EEPROM_CONFIG8_MAP8

#define EEPROM_CONFIG8_MAP8   3151

◆ EEPROM_CONFIG9_END

#define EEPROM_CONFIG9_END   1902

◆ EEPROM_CONFIG9_START

#define EEPROM_CONFIG9_START   1710

◆ EEPROM_DEFER_DELAY

#define EEPROM_DEFER_DELAY   MICROS_PER_SEC

Function Documentation

◆ 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:

◆ 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:

◆ 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()

uint8_t 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:

◆ 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:

Variable Documentation

◆ deferEEPROMWritesUntil

uint32_t deferEEPROMWritesUntil
extern