From ab37f833dba988b31d92833ff58109bfff1726af Mon Sep 17 00:00:00 2001
From: James Bielman <jamesjb@galois.com>
Date: Tue, 8 Jan 2013 10:25:51 -0800
Subject: [PATCH] MS5611: Fix CONFIG_MS5611_SERIAL definitions.

- Make sure the values are defined as integers.  We were always using
  SPI rather than using I2C when desired.
---
 ArduCopter/ArduCopter.pde | 4 ++--
 ArduCopter/config.h       | 2 +-
 ArduCopter/defines.h      | 3 +++
 ArduPlane/ArduPlane.pde   | 4 ++--
 ArduPlane/config.h        | 2 +-
 Tools/VARTest/config.h    | 2 +-
 6 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/ArduCopter/ArduCopter.pde b/ArduCopter/ArduCopter.pde
index 7bd96c274..b27814302 100644
--- a/ArduCopter/ArduCopter.pde
+++ b/ArduCopter/ArduCopter.pde
@@ -209,9 +209,9 @@ AP_Baro_BMP085 barometer;
   #elif CONFIG_BARO == AP_BARO_PX4
 AP_Baro_PX4 barometer;
   #elif CONFIG_BARO == AP_BARO_MS5611
-   #if CONFIG_MS5611_SERIAL == SPI
+   #if CONFIG_MS5611_SERIAL == AP_BARO_MS5611_SPI
 AP_Baro_MS5611 barometer(&AP_Baro_MS5611::spi);
-   #elif CONFIG_MS5611_SERIAL == I2C
+   #elif CONFIG_MS5611_SERIAL == AP_BARO_MS5611_I2C
 AP_Baro_MS5611 barometer(&AP_Baro_MS5611::i2c);
    #else
     #error Unrecognized CONFIG_MS5611_SERIAL setting.
diff --git a/ArduCopter/config.h b/ArduCopter/config.h
index 315068498..5df69c497 100644
--- a/ArduCopter/config.h
+++ b/ArduCopter/config.h
@@ -63,7 +63,7 @@
   #  define CONFIG_BARO     AP_BARO_BMP085
  # else // APM2 Production Hardware (default)
   #  define CONFIG_BARO          AP_BARO_MS5611
-  #  define CONFIG_MS5611_SERIAL SPI
+  #  define CONFIG_MS5611_SERIAL AP_BARO_MS5611_SPI
  # endif
 #elif CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL
  # define CONFIG_IMU_TYPE   CONFIG_IMU_SITL
diff --git a/ArduCopter/defines.h b/ArduCopter/defines.h
index ffc95a666..52a401b2f 100644
--- a/ArduCopter/defines.h
+++ b/ArduCopter/defines.h
@@ -424,6 +424,9 @@ enum gcs_severity {
 #define AP_BARO_MS5611    2
 #define AP_BARO_PX4       3
 
+#define AP_BARO_MS5611_SPI 1
+#define AP_BARO_MS5611_I2C 2
+
 // Error message sub systems and error codes
 #define ERROR_SUBSYSTEM_MAIN                1
 #define ERROR_SUBSYSTEM_RADIO               2
diff --git a/ArduPlane/ArduPlane.pde b/ArduPlane/ArduPlane.pde
index 33e82d6dd..9ad9c9317 100644
--- a/ArduPlane/ArduPlane.pde
+++ b/ArduPlane/ArduPlane.pde
@@ -155,9 +155,9 @@ static AP_Baro_BMP085 barometer;
   #elif CONFIG_BARO == AP_BARO_PX4
 static AP_Baro_PX4 barometer;
   #elif CONFIG_BARO == AP_BARO_MS5611
-   #if CONFIG_MS5611_SERIAL == SPI
+   #if CONFIG_MS5611_SERIAL == AP_BARO_MS5611_SPI
 static AP_Baro_MS5611 barometer(&AP_Baro_MS5611::spi);
-   #elif CONFIG_MS5611_SERIAL == I2C
+   #elif CONFIG_MS5611_SERIAL == AP_BARO_MS5611_I2C
 static AP_Baro_MS5611 barometer(&AP_Baro_MS5611::i2c);
    #else
     #error Unrecognized CONFIG_MS5611_SERIAL setting.
diff --git a/ArduPlane/config.h b/ArduPlane/config.h
index 0b10d81eb..ea3ad9d44 100644
--- a/ArduPlane/config.h
+++ b/ArduPlane/config.h
@@ -121,7 +121,7 @@
  #  define CONFIG_BARO     AP_BARO_BMP085
  # else // APM2 Production Hardware (default)
  #  define CONFIG_BARO          AP_BARO_MS5611
- #  define CONFIG_MS5611_SERIAL SPI
+ #  define CONFIG_MS5611_SERIAL AP_BARO_MS5611_SPI
  # endif
 #elif CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL
  # define A_LED_PIN        27
diff --git a/Tools/VARTest/config.h b/Tools/VARTest/config.h
index 5e30d213c..3ffa73ac2 100644
--- a/Tools/VARTest/config.h
+++ b/Tools/VARTest/config.h
@@ -54,7 +54,7 @@
 # define CONFIG_PITOT_SOURCE PITOT_SOURCE_ANALOG_PIN
 # define MAGNETOMETER ENABLED
 # define CONFIG_BARO     AP_BARO_MS5611
-# define CONFIG_MS5611_SERIAL SPI
+# define CONFIG_MS5611_SERIAL AP_BARO_MS5611_SPI
 
 # define A_LED_PIN        27
 # define B_LED_PIN        26
-- 
GitLab