Allow radio calibration to be set from ao-load
[fw/altos] / src / ao_config.c
index 3609ec068c7048fc3261b37b851f899dadc22bcc..4349bca856ac3a18e97aba1fe62f0939f3dc251d 100644 (file)
@@ -31,8 +31,12 @@ __xdata uint8_t ao_config_mutex;
  * For 434.550MHz, the frequency value is:
  *
  * 434.550e6 / (24e6 / 2**16) = 1186611.2
+ *
+ * This value is stored in a const variable so that
+ * ao-load can change it during programming for
+ * devices that have no eeprom for config data.
  */
-#define AO_CONFIG_DEFAULT_RADIO_CAL    1186611
+const uint32_t ao_radio_cal = 1186611;
 
 static void
 _ao_config_put(void)
@@ -57,7 +61,7 @@ _ao_config_get(void)
                memcpy(&ao_config.callsign, AO_CONFIG_DEFAULT_CALLSIGN,
                       sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
                ao_config.apogee_delay = AO_CONFIG_DEFAULT_APOGEE_DELAY;
-               ao_config.radio_cal = AO_CONFIG_DEFAULT_RADIO_CAL;
+               ao_config.radio_cal = ao_radio_cal;
                ao_config_dirty = 1;
        }
        if (ao_config.minor < AO_CONFIG_MINOR) {
@@ -71,7 +75,7 @@ _ao_config_get(void)
                }
                /* Fixups for minor version 3 */
                if (ao_config.minor < 3)
-                       ao_config.radio_cal = AO_CONFIG_DEFAULT_RADIO_CAL;
+                       ao_config.radio_cal = ao_radio_cal;
                ao_config.minor = AO_CONFIG_MINOR;
                ao_config_dirty = 1;
        }