Library to access multiple giro - with ability to setup them when starting

Revision:
2:606d0965f546
Parent:
1:816ba6bfbb20
--- a/FXAS21002CQ.cpp	Sat Aug 01 05:22:46 2015 +0000
+++ b/FXAS21002CQ.cpp	Mon Aug 24 14:29:35 2015 +0000
@@ -21,23 +21,11 @@
 struct FXAS21002CQ_CTRL_REG2_struct CTRL_REG2;
 struct FXAS21002CQ_CTRL_REG3_struct CTRL_REG3;
 
-struct FXAS21002CQ_Config_struct FXAS21002CQ_Config = 
-{
-    {CIRCULAR_BUFFER, 0}, // F_SETUP;
-    {HIGH_BW, SPI4, LOW_HP, DISABLED_HP, RANGE_1000}, // CTRL_REG0;
-    {DISABLED_ELE, DISABLED_ZTEVE, DISABLED_YTEVE, DISABLED_XTEVE}, // RT_CFG;
-    {DECREMENT_CNT, 0}, // RT_THS;
-    {0}, // RT_COUNT;
-    {NOT_RST, NOT_SELF_TEST, ODR_50, ACTIVE_GYRO, READY_GYRO}, // CTRL_REG1;
-    {FIFO_TO_INT2, FIFO_INT_DISABLE, RATE_TO_INT2, RATE_INT_DISABLE, DRDY_TO_INT2, DRDY_INT_DISABLE, INT_ACT_HIGH, INT_PUSH_PULL}, // CTRL_REG2;
-    {WRAP_TO_ZERO, INT2_IS_INTERUPT, NOT_DOUBLE_RANGE} // CTRL_REG3;
-};
 
 static int16_t dummy_int16_t = 0;
 static float dummy_float = 0.0f;
 
-
-FXAS21002CQ::FXAS21002CQ(I2C &i2c, uint8_t addr)
+FXAS21002CQ::FXAS21002CQ(I2C &i2c, const uint8_t addr, const struct FXAS21002CQ_Config_struct &FXAS21002CQ_Config)
 {
     _i2c = &i2c;
     _addr = addr;
@@ -61,6 +49,23 @@
     */
 }
 
+FXAS21002CQ::FXAS21002CQ(I2C &i2c, const uint8_t addr)
+{
+    const struct FXAS21002CQ_Config_struct FXAS21002CQ_Config = 
+    {
+        {CIRCULAR_BUFFER, 0}, // F_SETUP;
+        {HIGH_BW, SPI4, LOW_HP, DISABLED_HP, RANGE_1000}, // CTRL_REG0;
+        {DISABLED_ELE, DISABLED_ZTEVE, DISABLED_YTEVE, DISABLED_XTEVE}, // RT_CFG;
+        {DECREMENT_CNT, 0}, // RT_THS;
+        {0}, // RT_COUNT;
+        {NOT_RST, NOT_SELF_TEST, ODR_50, ACTIVE_GYRO, READY_GYRO}, // CTRL_REG1;
+        {FIFO_TO_INT2, FIFO_INT_DISABLE, RATE_TO_INT2, RATE_INT_DISABLE, DRDY_TO_INT2, DRDY_INT_DISABLE, INT_ACT_HIGH, INT_PUSH_PULL}, // CTRL_REG2;
+        {WRAP_TO_ZERO, INT2_IS_INTERUPT, NOT_DOUBLE_RANGE} // CTRL_REG3;
+    };
+    
+    FXAS21002CQ::FXAS21002CQ(i2c, addr, FXAS21002CQ_Config);
+}
+
 FXAS21002CQ::~FXAS21002CQ()
 {
     _i2c = 0;
@@ -195,3 +200,4 @@
     readRegs(FXAS21002CQ_TEMP, &res, sizeof(res));
     return (int8_t)res;
 }
+