/* * MSA301ForStuduino * * Adafruit_MSA301 v1.1.0 (https://github.com/adafruit/Adafruit_MSA301) を * 株式会社アーテックが Studuino 向けに改変したものです。 * 改変内容は同梱の README.md を参照してください。 * オリジナルの著作権表示およびライセンスは license.txt のとおりです。 */ /*! * @file MSA301ForStuduino.h */ #ifndef MSA301FORSTUDUINO_H #define MSA301FORSTUDUINO_H #include #include #include /*========================================================================= I2C ADDRESS/BITS -----------------------------------------------------------------------*/ #define MSA301_I2CADDR_DEFAULT (0x26) ///< Fixed I2C address #define MSA311_I2CADDR_DEFAULT (0x62) ///< Fixed I2C address /*=========================================================================*/ #define MSA301_REG_PARTID 0x01 ///< Register that contains the part ID #define MSA301_REG_OUT_X_L 0x02 ///< Register address for X axis lower byte #define MSA301_REG_RESRANGE 0x0F ///< Register address for resolution range #define MSA301_REG_ODR 0x10 ///< Register address for data rate setting #define MSA301_REG_POWERMODE 0x11 ///< Register address for power mode setting /** The accelerometer ranges */ #define MSA301_RANGE_2_G 0b00 ///< +/- 2g (default value) /** The accelerometer data rate */ #define MSA301_DATARATE_125_HZ 0b0111 ///< 125 Hz /** The accelerometer bandwidth */ #define MSA301_BANDWIDTH_250_HZ 0b1001 ///< 250 Hz /** The accelerometer power mode */ #define MSA301_NORMALMODE 0b00 ///< Normal (high speed) mode /** The accelerometer read resolution */ #define MSA301_RESOLUTION_8 0b11 ///< 8-bit resolution /** Class for hardware interfacing with an MSA301 accelerometer */ class Adafruit_MSA301 { // : public Adafruit_Sensor { public: Adafruit_MSA301(void); bool begin(uint8_t i2c_addr = MSA301_I2CADDR_DEFAULT, TwoWire *wire = &Wire); void read(); int8_t x, ///< The last read X acceleration in raw units y, ///< The last read Y acceleration in raw units z; ///< The last read Z acceleration in raw units private: Adafruit_I2CDevice *i2c_dev; }; /** Class for hardware interfacing with an MSA311 accelerometer */ class Adafruit_MSA311 : public Adafruit_MSA301 { public: Adafruit_MSA311(void); bool begin(uint8_t i2c_addr = MSA311_I2CADDR_DEFAULT, TwoWire *wire = &Wire); }; #endif