From df38ebd1116faeb659a5a3f5c43946c3438ca0fe Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Fri, 10 Apr 2009 17:59:08 +0200 Subject: pressure_config: Always store changed config to eeprom Signed-off-by: Michael Buesch --- pressure_control/firmware/main.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/pressure_control/firmware/main.c b/pressure_control/firmware/main.c index c5f8498..992555b 100644 --- a/pressure_control/firmware/main.c +++ b/pressure_control/firmware/main.c @@ -49,6 +49,22 @@ static struct eeprom_data EEMEM eeprom = { }; +/* Load the configuration from the EEPROM. */ +static void eeprom_load_config(void) +{ + eeprom_busy_wait(); + eeprom_read_block(&cfg, &eeprom.cfg, sizeof(cfg)); + eeprom_busy_wait(); +} + +/* Store the configuration to the EEPROM. */ +static void eeprom_store_config(void) +{ + eeprom_busy_wait(); + eeprom_write_block(&cfg, &eeprom.cfg, sizeof(cfg)); + eeprom_busy_wait(); +} + void get_pressure_config(struct pressure_config *ret) { uint8_t sreg; @@ -64,6 +80,7 @@ void set_pressure_config(struct pressure_config *new_cfg) sreg = irq_disable_save(); memcpy(&cfg, new_cfg, sizeof(cfg)); + eeprom_store_config(); irq_restore(sreg); } @@ -76,22 +93,6 @@ void get_pressure_state(struct pressure_state *ret) irq_restore(sreg); } -/* Load the configuration from the EEPROM. */ -static void eeprom_load_config(void) -{ - eeprom_busy_wait(); - eeprom_read_block(&cfg, &eeprom.cfg, sizeof(cfg)); - eeprom_busy_wait(); -} - -/* Store the configuration to the EEPROM. */ -static void eeprom_store_config(void) -{ - eeprom_busy_wait(); - eeprom_write_block(&cfg, &eeprom.cfg, sizeof(cfg)); - eeprom_busy_wait(); -} - /* Sensor measurement completed. * Called in IRQ context. */ void sensor_result(uint16_t mbar) -- cgit v1.2.3