Andy Pomfret / lsm303d

Dependents:   UoY-32C-lab8-exercise UoY-32C-lab5-lsm303d

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LSM303D.h Source File

LSM303D.h

00001 #include "mbed.h"
00002 
00003 typedef unsigned char u8;
00004 typedef signed short i16;
00005 typedef unsigned short u16;
00006 
00007 #pragma pack(push)
00008 #pragma pack(1)
00009 typedef struct {
00010     u8 x;
00011     u8 y;
00012     u8 z;
00013 } u8_3;
00014 typedef struct {
00015     i16 x;
00016     i16 y;
00017     i16 z;
00018 } i16_3;
00019 #pragma pack(pop)
00020 
00021 /** LSM303D class.
00022  * Communicates with LSM303D electronic compass over I<sup>2</sup>C.  Accelerometer,
00023  * magnetometer and temperature sensor supported.  Configurable sample rates
00024  * and full-scale ranges.  All LSM303D config registers available for raw
00025  * reads and writes if needed.
00026  *
00027  * Example:
00028  * @code
00029  * #include "mbed.h"
00030  * #include "lsm303d.h"
00031  *
00032  * LSM303D lsm303d(SDA, SCL);
00033  * lsm303d.setAccelRate(LSM303D::AccelRate::rate_25Hz);
00034  * lsm303d.setAccelScale(LSM303D::AccelScale::scale_8g);
00035  * 
00036  * int main() {
00037  *     short x, y, z;
00038  *     lsm303d.getRawAccelInto(x, y, z); // 16-bit signed, unscaled
00039  *     float xf, yf, zf;
00040  *     lsm303d.getAccelInto(xf, yf, zf); // floats, in g
00041  * }
00042  * @endcode
00043  */
00044 class LSM303D {
00045     
00046     friend class AccelScaleOption;
00047     friend class MagScaleOption;
00048     
00049     unsigned char const addr_8bit_;
00050     unsigned char accel_scale_;
00051     unsigned char mag_scale_;
00052     I2C i2c_;
00053 
00054 protected:
00055     // These classes are protected (rather than private) for inlusion in docs.
00056     // Wouldn't be necessary if mbed online toolchain allowed local Doxyfiles.
00057 
00058     template <class T>
00059     class RWRegister;
00060 
00061     /** Read-only register class.
00062      * @tparam T The underlying data type of the register.
00063      * Provides an interface onto the read-only registers of the LSM303D.
00064      * Operator overloading means that it can be treated as a const variable of
00065      * type T for most purposes.  Every read initiates an explicit
00066      * I<sup>2</sup>C transfer.
00067      */
00068     template <class T>
00069     class Register {
00070         friend class LSM303D;
00071         friend class RWRegister<T>;
00072     private:
00073         unsigned char addr_;
00074         LSM303D &parent_;
00075         Register(LSM303D &parent, unsigned char addr) :
00076             parent_(parent),
00077             addr_(addr | (sizeof(T)>1 ? 0x80 : 0x00)) {}
00078         /// Explicit read method.
00079         /// \return The current value of the register.
00080         virtual T read() const {
00081             T result;
00082             parent_.i2c_.lock();
00083             parent_.i2c_.write(parent_.addr_8bit_, (char *)&addr_, 1);
00084             parent_.i2c_.read(parent_.addr_8bit_, (char *)&result, sizeof(T));
00085             parent_.i2c_.unlock();
00086             return result;
00087         }
00088         /// Explicit cast to type T
00089         inline operator T() const {
00090             return read();
00091         }
00092     };
00093     
00094     /** Read-write register class.
00095      * @tparam T The underlying data type of the register.
00096      * Provides an interface onto the writable registers of the LSM303D.
00097      * Operator overloading means that it can be treated as a variable of type
00098      * T for most purposes.  Assignment from int is also explicitly supported
00099      * to allow integer literals to be used without qualification or casting.
00100      * The register value is cached on first read and updated on write, so read
00101      * accesses do not use the I<sup>2</sup>C bus.
00102      */
00103     template<class T>
00104     class RWRegister : public Register<T> {
00105         friend class LSM303D;
00106         using Register<T>::parent_;
00107         using Register<T>::addr_;
00108     private:
00109         mutable T cache_;
00110         mutable bool cached_;
00111     protected:
00112         RWRegister(LSM303D &parent, unsigned char addr) :
00113             Register<T>(parent, addr), cached_(false) {}
00114         /// Explicit write method.
00115         /// @param data The new value to write to the register.
00116         void write(T const &data) {
00117             char packet[sizeof(T)+1];
00118             packet[0] = addr_;
00119             memcpy(&packet[1], &data, sizeof(T));
00120             cache_ = data;
00121             cached_ = true;
00122             parent_.i2c_.lock();
00123             parent_.i2c_.write(parent_.addr_8bit_, packet, sizeof(T)+1);
00124             parent_.i2c_.unlock();
00125         }
00126         /// Explicit read method with cache.
00127         /// @return The current value of the register, from cache if available.
00128         virtual T read() const {
00129             if (!cached_) {
00130                 cache_ = Register<T>::read();
00131                 cached_ = true;
00132             }
00133             return cache_;
00134         }
00135         /// Equivalent to write().
00136         /// @param data The new value to write to the register.
00137         /// @return A reference to this object.
00138         inline RWRegister & operator= (T const &data) {
00139             write(data);
00140             return *this;
00141         }
00142         /// Equivalent to write(), with an explicit int parameter.
00143         /// @param data The new value to write to the register.
00144         /// @return A reference to this object.
00145         inline RWRegister & operator= (int const &data) {
00146             write(T(data));
00147             return *this;
00148         }
00149         /// Or-assignment operator.
00150         /// @param data The value to OR with the register's existing contents.
00151         /// @return A reference to this object.
00152         inline RWRegister & operator|= (T const &data) {
00153             write(read() | data);
00154             return *this;
00155         }
00156         /// Or-assignment operator, with an explicit int parameter.
00157         /// @param data The value to OR with the register's existing contents.
00158         /// @return A reference to this object.
00159         inline RWRegister & operator|= (int const &data) {
00160             write(read() | T(data));
00161             return *this;
00162         }
00163         /// And-assignment operator.
00164         /// @param data The value to AND with the register's existing contents.
00165         /// @return A reference to this object.
00166         inline RWRegister & operator&= (T const &data) {
00167             write(read() & data);
00168             return *this;
00169         }
00170         /// And-assignment operator, with an explicit int parameter.
00171         /// @param data The value to AND with the register's existing contents.
00172         /// @return A reference to this object.
00173         inline RWRegister & operator&= (int const &data) {
00174             write(read() & T(data));
00175             return *this;
00176         }
00177     };
00178 
00179     /** Class representing binary (on/off) options.
00180      * @tparam T The underlying data type of the register used to set the option.
00181      * Provides a user-friendly interface onto LSM303D options.
00182      */
00183     template <class T>
00184     class Option {
00185         friend class LSM303D;
00186     protected:
00187         T const bits_;
00188         RWRegister<T> & reg_;
00189         Option(RWRegister<T> & reg, int bits) :
00190             reg_(reg), bits_(T(bits)) {}
00191     public:
00192         /// Set the option 'on'.
00193         inline void operator() () const { reg_ |= bits_; };
00194         /// Set the option 'on' or 'off'.
00195         /// @param sr Option status: set to true for 'on', false for 'off'.
00196         inline void operator() (bool sr) const
00197             { if (sr) reg_ |= bits_; else reg_ &= ~bits_; };
00198     };
00199         
00200     const Register   <i16_3>  OUT_M;         ///< Triple magnetometer register
00201     const Register   <i16_3>  OFFSET_M;      ///< Triple magnetometer offset register
00202     const Register   <u8_3>   REFERENCE;     ///< Triple reference register
00203     const Register   <i16_3>  OUT_A;         ///< Triple accelerometer register
00204 
00205 public:
00206     const Register   <i16>    TEMP_OUT;      ///< TEMP_OUT register, read-only
00207     const Register   <u8>     STATUS_M;      ///< STATUS_M register, read-only
00208     const Register   <i16>    OUT_X_M;       ///< OUT_X_M register, read-only
00209     const Register   <i16>    OUT_Y_M;       ///< OUT_Y_M register, read-only
00210     const Register   <i16>    OUT_Z_M;       ///< OUT_Z_M register, read-only
00211     const Register   <u8>     WHO_AM_I;      ///< WHO_AM_I register, read-only
00212     const Register   <u8>     INT_SRC_M;     ///< INT_SRC_M register, read-only
00213     const Register   <i16>    OFFSET_X_M;    ///< OFFSET_X_M register, read-only
00214     const Register   <i16>    OFFSET_Y_M;    ///< OFFSET_Y_M register, read-only
00215     const Register   <i16>    OFFSET_Z_M;    ///< OFFSET_Z_M register, read-only
00216     const Register   <u8>     STATUS_A;      ///< STATUS_A register, read-only
00217     const Register   <i16>    OUT_X_A;       ///< OUT_X_A register, read-only
00218     const Register   <i16>    OUT_Y_A;       ///< OUT_Y_A register, read-only
00219     const Register   <i16>    OUT_Z_A;       ///< OUT_Z_A register, read-only
00220     const Register   <u8>     FIFO_SRC;      ///< FIFO_SRC register, read-only
00221     const Register   <u8>     IG_SRC1;       ///< IG_SRC1 register, read-only
00222     const Register   <u8>     IG_SRC2;       ///< IG_SRC2 register, read-only
00223     const Register   <u8>     CLICK_SRC;     ///< CLICK_SRC register, read-only
00224 
00225     RWRegister <u8>     INT_CTRL_M;  ///< INT_CTRL_M register, read-write
00226     RWRegister <u16>    INT_THS_M;   ///< INT_THS_M register, read-write
00227     RWRegister <u8>     REFERENCE_X; ///< REFERENCE_X register, read-write
00228     RWRegister <u8>     REFERENCE_Y; ///< REFERENCE_Y register, read-write
00229     RWRegister <u8>     REFERENCE_Z; ///< REFERENCE_Z register, read-write
00230     RWRegister <u8>     CTRL0;       ///< CTRL0 register, read-write
00231     RWRegister <u8>     CTRL1;       ///< CTRL1 register, read-write
00232     RWRegister <u8>     CTRL2;       ///< CTRL2 register, read-write
00233     RWRegister <u8>     CTRL3;       ///< CTRL3 register, read-write
00234     RWRegister <u8>     CTRL4;       ///< CTRL4 register, read-write
00235     RWRegister <u8>     CTRL5;       ///< CTRL5 register, read-write
00236     RWRegister <u8>     CTRL6;       ///< CTRL6 register, read-write
00237     RWRegister <u8>     CTRL7;       ///< CTRL7 register, read-write
00238     RWRegister <u8>     FIFO_CTRL;   ///< FIFO_CTRL register, read-write
00239     RWRegister <u8>     IG_CFG1;     ///< IG_CFG1 register, read-write
00240     RWRegister <u8>     IG_THS1;     ///< IG_THS1 register, read-write
00241     RWRegister <u8>     IG_DUR1;     ///< IG_DUR1 register, read-write
00242     RWRegister <u8>     IG_CFG2;     ///< IG_CFG2 register, read-write
00243     RWRegister <u8>     IG_THS2;     ///< IG_THS2 register, read-write
00244     RWRegister <u8>     IG_DUR2;     ///< IG_DUR2 register, read-write
00245     RWRegister <u8>     CLICK_CFG;   ///< CLICK_CFG register, read-write
00246     RWRegister <u8>     CLICK_THS;   ///< CLICK_THS register, read-write
00247     RWRegister <u8>     TIME_LIMIT;  ///< TIME_LIMIT register, read-write
00248     RWRegister <u8>     TIME_LATENCY;///< TIME_LATENCY register, read-write
00249     RWRegister <u8>     TIME_WINDOW; ///< TIME_WINDOW register, read-write
00250     RWRegister <u8>     Act_THS;     ///< Act_THS register, read-write
00251     RWRegister <u8>     Act_DUR;     ///< Act_DUR register, read-write
00252     
00253     // CTRL1
00254     /** AccelRate enum.
00255      * Provides friendly names for the accelerometer update rates
00256      * that are provided by the device.
00257      */
00258     enum class AccelRate {
00259         powerdown    = 0x00,    ///< power-down mode
00260         rate_3_125Hz = 0x10,    ///< 3.125Hz update rate
00261         rate_6_25Hz  = 0x20,    ///< 6.25Hz update rate
00262         rate_12_5Hz  = 0x30,    ///< 12.5Hz update rate
00263         rate_25Hz    = 0x40,    ///< 25Hz update rate
00264         rate_50Hz    = 0x50,    ///< 50Hz update rate
00265         rate_100Hz   = 0x60,    ///< 100Hz update rate
00266         rate_200Hz   = 0x70,    ///< 200Hz update rate
00267         rate_400Hz   = 0x80,    ///< 400Hz update rate
00268         rate_800Hz   = 0x90,    ///< 800Hz update rate
00269         rate_1600Hz  = 0xA0     ///< 1600Hz update rate
00270     };
00271     /** Sets the accelerometer update rate.
00272      * @param rate The new update rate.
00273      * Available values are:
00274      * - AccelRate::powerdown (power-down mode)
00275      * - AccelRate::rate_3_125Hz (3.125Hz)
00276      * - AccelRate::rate_6_25Hz (6.25Hz)
00277      * - AccelRate::rate_12_5Hz (12.5Hz)
00278      * - AccelRate::rate_25Hz (25Hz)
00279      * - AccelRate::rate_50Hz (50Hz)
00280      * - AccelRate::rate_100Hz (100Hz)
00281      * - AccelRate::rate_200Hz (200Hz)
00282      * - AccelRate::rate_400Hz (400Hz)
00283      * - AccelRate::rate_800Hz (800Hz)
00284      * - AccelRate::rate_1600Hz (1600Hz)
00285      */
00286     void setAccelRate(AccelRate const &rate);
00287 
00288     
00289     const Option<u8>  accel_enableX;     ///< Enable or disable x-axis accelerometer
00290     const Option<u8>  accel_enableY;     ///< Enable or disable y-axis accelerometer
00291     const Option<u8>  accel_enableZ;     ///< Enable or disable z-axis accelerometer
00292     const Option<u8>  accel_enableAll;   ///< Enable or disable all accelerometers
00293 
00294     // CTRL2
00295     /** AccelFilter enum.
00296      * Provides friendly names for the accelerometer antialiasing filter
00297      * frequencies that are provided by the device.
00298      */
00299     enum class AccelFilter {
00300         filter_773Hz = 0x00,    ///< 773Hz corner frequency
00301         filter_194Hz = 0x40,    ///< 194Hz corner frequency
00302         filter_362Hz = 0x80,    ///< 362Hz corner frequency
00303         filter_50Hz  = 0xC0     ///< 50Hz corner frequency
00304     };
00305     /** Sets the accelerometer antialiasing filter frequency.
00306      * @param freq The new frequency.
00307      * Available values are:
00308      * - AccelFilter::filter_773Hz
00309      * - AccelFilter::filter_194Hz
00310      * - AccelFilter::filter_362Hz
00311      * - AccelFilter::filter_50Hz
00312      */
00313     void setAccelFilterFreq(AccelFilter const &freq);
00314     /** AccelScale enum.
00315      * Provides friendly names for the accelerometer scale ranges
00316      * that are provided by the device.
00317      */
00318     enum class AccelScale {
00319         scale_2g  = 0x00,   ///< +-2g full scale
00320         scale_4g  = 0x08,   ///< +-4g full scale
00321         scale_6g  = 0x10,   ///< +-6g full scale
00322         scale_8g  = 0x18,   ///< +-8g full scale
00323         scale_16g = 0x20    ///< +-16g full scale
00324     };
00325     /** Sets the accelerometer scale range.
00326      * @param scale The new scale.
00327      * Available values are:
00328      * - AccelScale::scale_2g (+-2g)
00329      * - AccelScale::scale_4g (+-4g)
00330      * - AccelScale::scale_6g (+-6g)
00331      * - AccelScale::scale_8g (+-8g)
00332      * - AccelScale::scale_16g (+-16g)
00333      */
00334     void setAccelScale(AccelScale const &scale);
00335 
00336     // CTRL3
00337     const Option<u8>  INT1_enable_BOOT;  ///< Enable or disable "boot" source for INT1
00338     const Option<u8>  INT1_enable_CLICK; ///< Enable or disable "click" source for INT1
00339     const Option<u8>  INT1_enable_IG1;   ///< Enable or disable "inertial 1" source for INT1
00340     const Option<u8>  INT1_enable_IG2;   ///< Enable or disable "inertial 2" source for INT1
00341     const Option<u8>  INT1_enable_IGM;   ///< Enable or disable "magnetic" source for INT1
00342     const Option<u8>  INT1_enable_DRDY_A;///< Enable or disable "accelerometer data ready" source for INT1
00343     const Option<u8>  INT1_enable_DRDY_M;///< Enable or disable "magnetometer data ready" source for INT1
00344     const Option<u8>  INT1_enable_EMPTY; ///< Enable or disable "FIFO empty" source for INT1
00345     
00346     // CTRL4 concerns INT2 which is not broken out on the Pimoroni board
00347     
00348     // CTRL5
00349     const Option<u8>  temp_enable;   ///< Enable or disable temperature sensor
00350     const Option<u8>  LIR1_enable;   ///< Enable or disable latching interrupt requests for INT1
00351     
00352     /** MagRes enum.
00353      * Provides friendly names for the magnetometer resolution options
00354      * that are provided by the device.
00355      */
00356     enum class MagRes {
00357         high = 0x60,    ///< High resolution
00358         low  = 0x00,    ///< Low resolution
00359     };
00360     /** Sets the magnetometer resolution.
00361      * @param res The new resolution.
00362      * Available values are:
00363      * - MagRes::high (high resolution)
00364      * - MagRes::low (low resolution)
00365      */
00366     void setMagRes(MagRes const &res);
00367 
00368     /** MagRate enum.
00369      * Provides friendly names for the magnetometer update rates
00370      * that are provided by the device.
00371      */
00372     enum class MagRate {
00373         rate_3_125Hz = 0x00,    ///< 3.125Hz update rate
00374         rate_6_25Hz  = 0x04,    ///< 6.25Hz update rate
00375         rate_12_5Hz  = 0x08,    ///< 12.5Hz update rate
00376         rate_25Hz    = 0x0C,    ///< 25Hz update rate
00377         rate_50Hz    = 0x10,    ///< 50Hz update rate
00378         rate_100Hz   = 0x14     ///< 100Hz update rate
00379     };    
00380     /** Sets the magnetometer update rate.
00381      * @param rate The new update rate.
00382      * Available values are:
00383      * - MagRate::rate_3_125Hz (3.125Hz)
00384      * - MagRate::rate_6_25Hz (6.25Hz)
00385      * - MagRate::rate_12_5Hz (12.5Hz)
00386      * - MagRate::rate_25Hz (25Hz)
00387      * - MagRate::rate_50Hz (50Hz)
00388      * - MagRate::rate_100Hz (100Hz)
00389      * Note that the 100Hz update rate is available only if the accelerometer
00390      * update rate is set to 50Hz or higher or the accelerometer is set to
00391      * power-down mode (see setAccelRate()).  Failing to meet these conditions
00392      * will lead to undefined behaviour.
00393      */
00394     void setMagRate(MagRate const &rate);
00395 
00396     // CTRL6
00397     /** MagScale enum.
00398      * Provides friendly names for the magnetometer scale ranges
00399      * that are provided by the device.
00400      */
00401     enum class MagScale {
00402         scale_2G  = 0x00,   ///< +-2 Gauss
00403         scale_4G  = 0x20,   ///< +-4 Gauss
00404         scale_8G  = 0x40,   ///< +-8 Gauss
00405         scale_12G = 0x60    ///< +-12 Gauss
00406     };
00407     /** Sets the magnetometer scale range.
00408      * @param scale The new scale.
00409      * Available values are:
00410      * - MagScale::scale_2G (+-2 Gauss)
00411      * - MagScale::scale_4G (+-4 Gauss)
00412      * - MagScale::scale_8G (+-8 Gauss)
00413      * - MagScale::scale_12G (+-16 Gauss)
00414      */
00415     void setMagScale(MagScale const &scale);
00416 
00417     // CTRL7
00418     /** MagScale enum.
00419      * Provides friendly names for the magnetometer modes that are supported
00420      * by the device.
00421      */
00422     enum class MagMode {
00423         continuous  = 0x00, ///< Continous conversion mode
00424         single      = 0x01, ///< Single conversion mode
00425         powerdown   = 0x02  ///< Magnetometer power-down mode
00426     };
00427     /** Sets the magnetometer mode.
00428      * @param mode The new mode.
00429      * Available values are:
00430      * - MagMode::continuous (continuous conversion mode)
00431      * - MagMode::single (single-conversion mode)
00432      * - MagMode::powerdown (power-down mode)
00433      */
00434     void setMagMode(MagMode const &mode);
00435 
00436     /** Constructor.
00437      * @param sda The pin to use for the I^^2^^C SDA signal.
00438      * @param scl The pin to use for the I^^2^^C SCL signal.
00439      * @param i2c_addr The 7-bit I<sup>2</sup>C address.  Defaults to 0x1D, but
00440      * this can be overridden to 0x1E with a jumper setting on the device allowing
00441      * two LSM303D devices to coexist on a bus.
00442      */
00443     LSM303D(PinName sda, PinName scl, unsigned char i2c_addr = 0x1D);
00444     
00445     /** Gets the raw (signed 16-bit integer) X-axis acceleration value.
00446      * @return The raw acceleration value.
00447      */
00448     inline i16 getRawAccelX() { return OUT_X_A; };
00449     /** Gets the raw (signed 16-bit integer) Y-axis acceleration value.
00450      * @return The raw acceleration value.
00451      */
00452     inline i16 getRawAccelY() { return OUT_Y_A; };
00453     /** Gets the raw (signed 16-bit integer) Z-axis acceleration value.
00454      * @return The raw acceleration value.
00455      */
00456     inline i16 getRawAccelZ() { return OUT_Z_A; };
00457     /** Gets the scaled (float) X-axis acceleration value in g.
00458      * @return The scaled acceleration value in g.
00459      */
00460     inline float getAccelX() { return (float)OUT_X_A / accel_scale_ / 32768; };
00461     /** Gets the scaled (float) Y-axis acceleration value in g.
00462      * @return The scaled acceleration value in g.
00463      */
00464     inline float getAccelY() { return (float)OUT_Y_A / accel_scale_ / 32768; };
00465     /** Gets the scaled (float) Z-axis acceleration value in g.
00466      * @return The scaled acceleration value in g.
00467      */
00468     inline float getAccelZ() { return (float)OUT_Z_A / accel_scale_ / 32768; };
00469     /** Reads the raw (signed 16-bit integer) acceleration values into the three
00470      * axis value containers provided.
00471      * @param x Container for the X value.
00472      * @param y Container for the Y value.
00473      * @param z Container for the Z value.
00474      */
00475     void getRawAccelInto(short &x, short &y, short &z);
00476     /** Reads the scaled (float) acceleration values in g into the three
00477      * axis value containers provided.
00478      * @param x Container for the X value.
00479      * @param y Container for the Y value.
00480      * @param z Container for the Z value.
00481      */
00482     void getAccelInto(float &x, float &y, float &z);
00483     
00484     /** Gets the raw (signed 16-bit integer) X-axis magnetometer value.
00485      * @return The raw magnetometer value.
00486      */
00487     inline i16 getRawMagX() { return OUT_X_M; };
00488     /** Gets the raw (signed 16-bit integer) Y-axis magnetometer value.
00489      * @return The raw magnetometer value.
00490      */
00491     inline i16 getRawMagY() { return OUT_Y_M; };
00492     /** Gets the raw (signed 16-bit integer) Z-axis magnetometer value.
00493      * @return The raw magnetometer value.
00494      */
00495     inline i16 getRawMagZ() { return OUT_Z_M; };
00496     /** Gets the scaled (float) X-axis magnetometer value in Gauss.
00497      * @return The scaled magnetometer value in Gauss.
00498      */
00499     inline float getMagX() { return (float)OUT_X_M / mag_scale_ / 32768; };
00500     /** Gets the scaled (float) Y-axis magnetometer value in Gauss.
00501      * @return The scaled magnetometer value in Gauss.
00502      */
00503     inline float getMagY() { return (float)OUT_Y_M / mag_scale_ / 32768; };
00504     /** Gets the scaled (float) Z-axis magnetometer value in Gauss.
00505      * @return The scaled magnetometer value in Gauss.
00506      */
00507     inline float getMagZ() { return (float)OUT_Z_M / mag_scale_ / 32768; };
00508     /** Reads the raw (signed 16-bit integer) magnetometer values into the three
00509      * axis value containers provided.
00510      * @param x Container for the X value.
00511      * @param y Container for the Y value.
00512      * @param z Container for the Z value.
00513      */
00514     void getRawMagInto(short &x, short &y, short &z);
00515     /** Reads the scaled (float) magnetometer values in Gauss into the three
00516      * axis value containers provided.
00517      * @param x Container for the X value.
00518      * @param y Container for the Y value.
00519      * @param z Container for the Z value.
00520      */
00521     void getMagInto(float &x, float &y, float &z);
00522     
00523     /** Reads the scaled (float) temperature values in &deg; C.
00524      * @return The current temperature.
00525      * Note that testing suggests this to be an inaccurate temperature sensor!
00526      * To read the raw temperature value, simply use the TEMP_OUT register directly.
00527      */
00528     inline float getTemp() { return TEMP_OUT / 8.0 + 25; };
00529     
00530 };