Git Product home page Git Product logo

eevar's Introduction

eeVar

eeVar lets to define, use, read and write variables stored in AVR's EEPROM memory and configure the AVR device using data stored in EEPROM

Variables

Simple EEPROM variable

EEPROM_VAR(var_type, var_name)

Defines EEPROM stored variable of type var_type, named var_name giving it a a value to be strored in EEPROM. This variable should be initialized using EEPROM_READ() before use.

Example:

EEPROM_VAR(uint8_t, ledBrightness) = 127;

main()
{
  EEPROM_READ(ledBrightness);
  setPWM(ledBrightness);
}

Automatic EEPROM variable

EEPROM_AUTO_VAR(var_type, var_name)

Defines EEPROM stored variable of type var_type, named var_name with a value strored in EEPROM. This value will be automaticaly read into var_name in RAM in .init8 section just before the main() function starts execution. Then, the definition alone is enough to get pre-initialized variable ready to use as soon as the program starts.

Example:

EEPROM_AUTO_VAR(uint8_t, ledBrightness) = 127;

main()
{
  setPWM(ledBrightness);
}

Read value

EEPROM_READ(x)

Reads value of a variable from EEPROM to RAM memory. This must be a variable defined with EEPROM_VAR or 'EEPROM_AUTO_VAR` macros.

Example:

EEPROM_VAR(uint8_t, ledBrightness) = 127;

main()
{
  EEPROM_READ(ledBrightness);
  setPWM(ledBrightness);
}

Store value

EEPROM_WRITE(x)

Writes value of a variable from RAM to EEPROM memory. This must be a variable defined with EEPROM_VAR or EEPROM_AUTO_VAR macros.

Example:

EEPROM_AUTO_VAR(uint8_t, ledBrightness) = 127;

main()
{
  int newLedBrightness = checkButtons(ledBrightness);
  setPWM(newLedBrightness);
  if (newLedBrightness != ledBrightness)
  {
    ledBrightness= newLedBrightness;
    EEPORM_WRITE(ledBrightness); // EEPORM_WRITE(newLedBrightness) wouldn't work
  }
}

Configuration

Config set

EEPROM_CONFIG(name)

Defines set of configuration data as a vetor filled with EEPROM_SETUP entries. This may be complete device initialization or partial configuration so there can be many sets in system.

Note

Setting just few registers directly in code may be more efficient than using EEPROM config.

Config entry

EEPROM_SETUP(reg, value)

Defines register/value as a pair of configuration set.

Using configuration

EEPROM_CONFIGURE(name)

Rewrites configuration set from EEPROM to AVR's registers. Since it calls a function which does the job in loop the amount of used program memory does not depend on the number of entries in config data set. This technique may save some program bytes at a cost of EEPROM memory. On devices with small prghram memories it may be crucial.

Example:

EEPORM_CONFIG(pwmEnable) =
{
  EEPROM_SETUP(PWMREG0, 1 << PWM_EN | 1 << PWM_PRESC_2),
  EEPROM_SETUP(PWMMAX, 128)
};

main()
{
  EEPROM_CONFIGURE(pwmEnable);
}

eevar's People

Contributors

promyclon avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.