Basic component library for the FXAS21000 gyro from Freescale

Dependents:   Hello_FXAS21000 Multi-Sensor Freescale_Multi-Sensor_Shield FRDM-STBC-AGM01 ... more

FXAS21000.h

Committer:
JimCarver
Date:
2014-04-19
Revision:
0:4cfc774d6d85
Child:
1:88a036a417bf

File content as of revision 0:4cfc774d6d85:

#ifndef FXAS21000_H
#define FXAS21000_H

#include "mbed.h"


// MMA8652 Slave Address
#define FXAS21000_SLAVE_ADDR 0x40

// MMA8652 internal register addresses
#define FXAS21000_STATUS 0x00
#define FXAS21000_WHOAMI 0x0C
#define FXAS21000_XYZ_DATA_CFG 0x0E
#define FXAS21000_CTRL_REG0 0x0D
#define FXAS21000_CTRL_REG1 0x13
#define FXAS21000_WHOAMI_VAL 0xD1

class FXAS21000
{
public:
    /**
    * FXAS21000 constructor
    *
    * @param sda SDA pin
    * @param sdl SCL pin
    * 
    */
    FXAS21000(PinName sda, PinName scl);
 
    
    /**
    * Get the Gyro values
    * Result is floating point degrees / second
    *
    * @param floating point array where the results will be placed
    */
    void ReadXYZ(float * a);

    
    /**
    * Get the Gyro values
    * Result is signed 16 bit value
    *
    * @param int16_t point array where the results will be placed
    */
    void ReadXYZraw(int16_t * t);

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

    I2C _i2c;
    /** Set the device in active mode
    */
    void begin( void);
    
    void RegRead( char reg, char * d, int len);


};

#endif