Library to access multiple giro - with ability to setup them when starting
Revision 2:606d0965f546, committed 2015-08-24
- Comitter:
- Pythia
- Date:
- Mon Aug 24 14:29:35 2015 +0000
- Parent:
- 1:816ba6bfbb20
- Commit message:
- Initial version of the software
Changed in this revision
FXAS21002CQ.cpp | Show annotated file Show diff for this revision Revisions of this file |
FXAS21002CQ.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 816ba6bfbb20 -r 606d0965f546 FXAS21002CQ.cpp --- 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; } +
diff -r 816ba6bfbb20 -r 606d0965f546 FXAS21002CQ.h --- a/FXAS21002CQ.h Sat Aug 01 05:22:46 2015 +0000 +++ b/FXAS21002CQ.h Mon Aug 24 14:29:35 2015 +0000 @@ -181,7 +181,7 @@ @endcode */ -/** FXOS8700Q driver class +/** FXAS21002CQ driver class */ class FXAS21002CQ : public MotionSensor { @@ -198,7 +198,7 @@ /** Read the ID from a whoAmI register @return The device whoAmI register contents */ - uint8_t whoAmI(void) ; + virtual uint8_t whoAmI(void) ; virtual void enable(void) const; virtual void disable(void) const; @@ -220,7 +220,8 @@ @param i2c a configured i2c object @param addr addr of the I2C peripheral as wired */ - FXAS21002CQ(I2C &i2c, uint8_t addr); + FXAS21002CQ(I2C &i2c, const uint8_t addr); + FXAS21002CQ(I2C &i2c, const uint8_t addr, const struct FXAS21002CQ_Config_struct &FXAS21002CQ_Config); /** FXAS21002CQ deconstructor */