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

FXLS8471Q.h

Committer:
JimCarver
Date:
2014-04-19
Revision:
1:c80be04510fe
Parent:
0:f89f2dc4b003
Child:
2:6aae25fe9ab4

File content as of revision 1:c80be04510fe:

/* Copyright (c) 2010-2011 mbed.org, MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


#ifndef FXLS8471Q_H
#define FXLS8471Q_H

#include "mbed.h"

// FXLS8471Q internal register addresses

#define FXLS8471Q_STATUS 0x00
#define FXLS8471Q_OUT_X_MSB 0x01
#define FXLS8471Q_WHOAMI 0x0D
#define FXLS8471Q_XYZ_DATA_CFG 0x0E
#define FXLS8471Q_CTRL_REG1 0x2A
#define FXLS8471Q_WHOAMI_VAL 0x6A

class FXLS8471Q
{
public:
  /**
  * FXOS8700Q constructor
  *
  * @param mosi MOSI pin
  * @param miso MISO pin
  * @param scl  SCL  pin
  * @param cs   Device Chip Select pin
  */
FXLS8471Q(PinName mosi, PinName miso, PinName scl, PinName cs);


  /**
   * Get XYZ axis acceleration in G's
   *
   * @param res array where acceleration data will be stored
   */
void ReadXYZ(float * a);
  
  /**
   * Get XYZ axis acceleration, signed 16 bit values
   *
   * @param res array where acceleration data will be stored
   */
void ReadXYZraw(int16_t * d);

  /**
   * Get the value of the WHO_AM_I register
   *
   * @returns WHO_AM_I value
   */
char getWhoAmI(void);
      
private:

    SPI _spi;
    DigitalOut _spi_cs;

    void begin( void);
    void RegWrite( int reg, int * d, int len);    
    void RegRead( int reg, int * d, int len);


};

#endif