Digital Scale  1.0
Digital Scale
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Functions | Variables
config.c File Reference

Routines for handling Configuration Data. More...

Functions

static void DefaultConfig (void)
 Loads default config values into conf-struct and stores it in non volatile Memory. More...
 
void ReadConfig (void)
 Reads the Config-Struct from EEPROM into config. More...
 
void WriteConfig (void)
 Writes the Config-Struct to EEPROM. More...
 

Variables

confStruct_t config
 The Configuration. It is read on startup from the EEPROM. More...
 
confStruct_t EEMEM eepConfig
 This struct will be stored in the EEPROM and is contained in the Production File. More...
 

Detailed Description

Routines for handling Configuration Data.

Author
Robert Loos rober.nosp@m.t.lo.nosp@m.os@lo.nosp@m.oswe.nosp@m.b.de

The routines here define the configuration memory and setting up the default configuration.

Function Documentation

static void DefaultConfig ( void  )
static

Loads default config values into conf-struct and stores it in non volatile Memory.

This function is mostly useful during development but I recommend to leave it functional. if you change the config struct always also change CONF_MAGIC. It will reprogram the EEPROM with default values then. This prevents surprises with different config-structs. Especially in devices already in the field it would lead to unpredictable results if the configuration memory format would not be compatible with the current version.

Note
Keep the values here in sync with the values in eepConfig if you don't like surprises!
void ReadConfig ( void  )

Reads the Config-Struct from EEPROM into config.

Only the config-struct in RAM will be used. Changes in config will only become permanent if you use a write-command. There is a configDirty-flag that is set by every routine that changes config and is used to remind the user to execute a write-command.

void WriteConfig ( void  )

Writes the Config-Struct to EEPROM.

Variable Documentation

confStruct_t config

The Configuration. It is read on startup from the EEPROM.

confStruct_t EEMEM eepConfig
Initial value:
=
{
.magic=CONF_MAGIC,
.cal_num=100000,
.cal_denom=210000,
.isCalibrated=false,
}

This struct will be stored in the EEPROM and is contained in the Production File.

'New' devices are programmed using the production file which also can write the default EEPROM content and the fuses.