Commit b715dc65 authored by Sven Greiner's avatar Sven Greiner
Browse files

Use non-atomic option write to save space

parent b5e55793
......@@ -144,16 +144,6 @@ void blink(uint8_t count, uint16_t speed) {
OCR0B = old_pwm;
}
/**
* Write current options to EEPROM.
*/
void save_options(void) {
// Not necessary to use eeprom_update_byte() because options will usually be
// written only if they have changed.
// Store inverted so that a read from uninitialized EEPROM results in 0.
eeprom_write_byte((uint8_t *)EEPROM_OPTIONS, ~options.raw);
}
/**
* Internal function to erase or dirty write a byte to EEPROM.
*
......@@ -191,6 +181,19 @@ void eeprom_erase_byte(const uint8_t address) {
eeprom_erase_or_write_byte(address, 0, (1 << EEPM0));
}
/**
* Write current options to EEPROM.
*/
void save_options(void) {
// Not necessary to use eeprom_update_byte() because options will usually be
// written only if they have changed.
// Using non-atomic erase and write to save some bytes by not using avr-libc
// method eeprom_write_byte().
// Store inverted so that a read from uninitialized EEPROM results in 0.
eeprom_erase_byte(EEPROM_OPTIONS);
eeprom_onlywrite_byte(EEPROM_OPTIONS, ~options.raw);
}
/**
* Write current output level to EEPROM with wear leveling.
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment