summaryrefslogtreecommitdiffstats
path: root/pressure_control/firmware/main.c
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2009-04-10 17:59:08 +0200
committerMichael Buesch <mb@bu3sch.de>2009-04-10 17:59:08 +0200
commitdf38ebd1116faeb659a5a3f5c43946c3438ca0fe (patch)
tree54ebffda8f4612d671307cc79626a0e37e1ab2c5 /pressure_control/firmware/main.c
parent3e7e105743960bdfce80f5ee7b29aecc48406d6f (diff)
downloadcnc-df38ebd1116faeb659a5a3f5c43946c3438ca0fe.tar.xz
cnc-df38ebd1116faeb659a5a3f5c43946c3438ca0fe.zip
pressure_config: Always store changed config to eeprom
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Diffstat (limited to 'pressure_control/firmware/main.c')
-rw-r--r--pressure_control/firmware/main.c33
1 files 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)
bues.ch cgit interface