Simon Hawe / D7_MLX_AND_BAT

Dependencies:   X_NUCLEO_IKS01A1 MLX90614 d7a_1x wizzi-utils

Fork of D7A_1x_demo_sensors_OS5 by WizziLab

Revision:
12:6a1158950a9e
Parent:
9:25180d6a4c3a
Parent:
11:7938e138cb7a
Child:
14:c652f8f098e2
--- a/main.cpp	Mon Feb 06 10:05:25 2017 +0000
+++ b/main.cpp	Wed Feb 08 15:59:12 2017 +0000
@@ -109,8 +109,8 @@
     // Select the sensors available on the sh2050
     // -1 : disable, 0 : simu, 1 : hardware   
     // -----------------------------------------------
-    #define _MAG_EN_                (0)
-    #define _ACC_EN_                (0)
+    #define _MAG_EN_                (1)
+    #define _ACC_EN_                (1)
     #define _PRE_EN_                (1)
     #define _HUM_EN_                (1)
     #define _TEM1_EN_               (1)
@@ -128,7 +128,7 @@
 #endif
 
 // Enable DBG led blinking (ms)
-#define DGB_LED_BLINK_PERIOD        (1000)
+#define DGB_LED_BLINK_PERIOD        (200)
 
 // Defaults
 #ifndef _MAG_EN_
@@ -436,6 +436,8 @@
     err = CALL_METH(temp_sensor1, GetTemperature, &tmp, 0.0f)? true : false;
     buf[0] = float2_to_int(tmp);    
     return err;
+#else
+    return false;
 #endif
 }
 SENSOR_THREAD_CTX(tem1, TEM1_VALUE_FILE_ID, TEM1_CFG_FILE_ID, tem1_get_value, 1);
@@ -709,7 +711,7 @@
 
 #if (_HUM_EN_ > 0 || _TEM1_EN_ > 0 || _MAG_EN_ > 0 || _ACC_EN_  > 0 || _GYR_EN_ > 0 || _PRE_EN_ > 0 || _TEM2_EN_ > 0)
     // Open I2C and initialise the sensors
-    DevI2C ext_i2c(SENSOR_I2C_SDA, SENSOR_I2C_SCL);
+    DevI2C ext_i2c(SENSOR_I2C_SDA, SENSOR_I2C_SCL);    
 #endif
 
 #if (_HUM_EN_ > 0 || _TEM1_EN_ > 0)
@@ -717,21 +719,33 @@
     ASSERT(Init_HTS221(humidity_sensor), "Failed to init HTS221\r\n");
     temp_sensor1 = humidity_sensor;
 #endif // _TEM_EN_
-#if (_MAG_EN_ > 0)
-    magnetometer = new LIS3MDL(ext_i2c);
-    ASSERT(Init_LIS3MDL(magnetometer), "Failed to init LIS3MDL\r\n");
-#endif // _MAG_EN_
-#if (_ACC_EN_ > 0 || _GYR_EN_ > 0)
-    accelerometer = new LSM6DS0(ext_i2c);
-    ASSERT(Init_LSM6DS0(accelerometer), "Failed to init LSM6DS0\r\n");
-    gyroscope = accelerometer;
-#endif // _ACC_EN_ || _GYR_EN_
 #if (_PRE_EN_ > 0 || _TEM2_EN_ > 0)
     pressure_sensor = new LPS25H(ext_i2c);
     ASSERT(Init_LPS25H(pressure_sensor), "Failed to init LPS25H\r\n");
     temp_sensor2 = pressure_sensor;
 #endif // _PRE_EN_
 
+#if defined(TARGET_STM32L152RE)
+    #if (_MAG_EN_ > 0)
+        magnetometer = new LIS3MDL(ext_i2c);
+        ASSERT(Init_LIS3MDL(magnetometer), "Failed to init LIS3MDL\r\n");
+    #endif // _MAG_EN_
+    #if (_ACC_EN_ > 0 || _GYR_EN_ > 0)
+        accelerometer = new LSM6DS0(ext_i2c);
+        ASSERT(Init_LSM6DS0(accelerometer), "Failed to init LSM6DS0\r\n");
+        gyroscope = accelerometer;
+    #endif // _ACC_EN_ || _GYR_EN_
+#elif defined(TARGET_STM32L432KC)
+    #if (_ACC_EN_ > 0)
+        accelerometer = new LSM303C_ACC_Sensor(ext_i2c);
+        ASSERT(Init_LSM303C_ACC(accelerometer), "Failed to init LSM303C_ACC\r\n");
+    #endif // _ACC_EN_
+    #if (_MAG_EN_ > 0)
+        magnetometer = new LSM303C_MAG_Sensor(ext_i2c);
+        ASSERT(Init_LSM303C_MAG(magnetometer), "Failed to init LSM303C_MAG\r\n");
+    #endif // _MAG_EN_
+#endif
+
     osStatus status;
 
     // Start sensors threads