From 0226c55f96a59b757029589de15cfe718d24fc6c Mon Sep 17 00:00:00 2001 From: lady ada Date: Thu, 9 Dec 2021 13:43:51 -0500 Subject: [PATCH] add MSA311 support --- Adafruit_MSA301.cpp | 26 +++++++++++++++++++------- Adafruit_MSA301.h | 9 +++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Adafruit_MSA301.cpp b/Adafruit_MSA301.cpp index 0eebe96..088dd0f 100644 --- a/Adafruit_MSA301.cpp +++ b/Adafruit_MSA301.cpp @@ -22,14 +22,7 @@ * */ -#if ARDUINO >= 100 -#include "Arduino.h" -#else -#include "WProgram.h" -#endif - #include -#include /**************************************************************************/ /*! @@ -38,6 +31,25 @@ /**************************************************************************/ Adafruit_MSA301::Adafruit_MSA301() {} +/**************************************************************************/ +/*! + @brief Instantiates a new MSA311 class +*/ +/**************************************************************************/ +Adafruit_MSA311::Adafruit_MSA311() {} + +/*! + * @brief Sets up the hardware and initializes I2C + * @param i2c_address + * The I2C address to be used. + * @param wire + * The Wire object to be used for I2C connections. + * @return True if initialization was successful, otherwise false. + */ +bool Adafruit_MSA311::begin(uint8_t i2c_address, TwoWire *wire) { + return Adafruit_MSA301::begin(i2c_address, wire); +} + /*! * @brief Sets up the hardware and initializes I2C * @param i2c_address diff --git a/Adafruit_MSA301.h b/Adafruit_MSA301.h index 6da49e5..93d010b 100644 --- a/Adafruit_MSA301.h +++ b/Adafruit_MSA301.h @@ -14,6 +14,7 @@ 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 @@ -173,4 +174,12 @@ private: int32_t _sensorID; }; + +/** 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