Rev 0.1 Simple operation of just X, Y, Z values in floating point G's

Dependents:   Hello_FXLS8471Q Multi-Sensor sensor AerCloud_MutliTech_Socket_Modem_Example ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FXLS8471Q.h Source File

FXLS8471Q.h

00001 /* Copyright (c) 2010-2011 mbed.org, MIT License
00002 *
00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00004 * and associated documentation files (the "Software"), to deal in the Software without
00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
00007 * Software is furnished to do so, subject to the following conditions:
00008 *
00009 * The above copyright notice and this permission notice shall be included in all copies or
00010 * substantial portions of the Software.
00011 *
00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017 */
00018 
00019 
00020 #ifndef FXLS8471Q_H
00021 #define FXLS8471Q_H
00022 
00023 #include "mbed.h"
00024 
00025 // FXLS8471Q internal register addresses
00026 
00027 #define FXLS8471Q_STATUS 0x00
00028 #define FXLS8471Q_OUT_X_MSB 0x01
00029 #define FXLS8471Q_WHOAMI 0x0D
00030 #define FXLS8471Q_XYZ_DATA_CFG 0x0E
00031 #define FXLS8471Q_CTRL_REG1 0x2A
00032 #define FXLS8471Q_WHOAMI_VAL 0x6A
00033 
00034 /**
00035  * FXLS8471Q Xtrinsic accelerometer on SPI
00036  */
00037 class FXLS8471Q
00038 {
00039 public:
00040     /**
00041     * FXLS8471Q constructor
00042     *
00043     * @param mosi MOSI pin
00044     * @param miso MISO pin
00045     * @param scl  SCL  pin
00046     * @param cs   Device Chip Select pin
00047     */
00048     FXLS8471Q(PinName mosi, PinName miso, PinName scl, PinName cs);
00049 
00050     /**
00051      * Get XYZ axis acceleration in G's as floating point
00052      *
00053      * @param res array where acceleration data will be stored
00054      */
00055     void ReadXYZ(float * a);
00056 
00057     /**
00058      * Get XYZ axis acceleration as signed 16 bit values
00059      *
00060      * @param res array where acceleration data will be stored
00061      */
00062     void ReadXYZraw(int16_t * d);
00063 
00064     /**
00065      * Get the value of the WHO_AM_I register
00066      *
00067      * @returns WHO_AM_I value
00068      */
00069     char getWhoAmI(void);
00070 
00071 private:
00072     SPI _spi;
00073 
00074     DigitalOut _spi_cs;
00075 
00076     /**
00077      * Set the device in active mode
00078      */
00079     void begin( void);
00080 
00081     void RegWrite( int reg, int * d, int len);
00082 
00083     void RegRead( int reg, int * d, int len);
00084 };
00085 
00086 #endif