Basic component library for the FXAS21000 gyro from Freescale

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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FXAS21000.h Source File

FXAS21000.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 #ifndef FXAS21000_H
00020 #define FXAS21000_H
00021 
00022 #include "mbed.h"
00023 
00024 
00025 /**
00026  * MMA8652 Slave Address
00027  */
00028 #define FXAS21000_SLAVE_ADDR 0x40
00029 
00030 // MMA8652 internal register addresses
00031 #define FXAS21000_STATUS 0x00
00032 #define FXAS21000_WHOAMI 0x0C
00033 #define FXAS21000_XYZ_DATA_CFG 0x0E
00034 #define FXAS21000_CTRL_REG0 0x0D
00035 #define FXAS21000_CTRL_REG1 0x13
00036 #define FXAS21000_WHOAMI_VAL 0xD1
00037 
00038 /**
00039  * FXAS21000 gyroscope on I2C
00040  */
00041 class FXAS21000
00042 {
00043 public:
00044     /**
00045      * FXAS21000 constructor
00046      *
00047      * @param sda SDA pin
00048      * @param sdl SCL pin
00049      */
00050     FXAS21000(PinName sda, PinName scl);
00051  
00052     /**
00053      * Get the Gyro values as floating point degrees / second
00054      *
00055      * @param floating point array where the results will be placed
00056      */
00057     void ReadXYZ(float * a);
00058 
00059     /**
00060      * Get the Gyro values as signed 16 bit value
00061      *
00062      * @param int16_t point array where the results will be placed
00063      */
00064     void ReadXYZraw(int16_t * t);
00065    
00066     /**
00067      * Get the value of the WHO_AM_I register
00068      *
00069      * @returns DEVICE_ID value == 0xD1
00070      */
00071     char getWhoAmI(void);
00072     
00073 private:
00074     I2C _i2c;
00075 
00076     /**
00077      * Set the device in active mode
00078      */
00079     void begin( void);
00080     
00081     void RegRead( char reg, char * d, int len);
00082 };
00083 
00084 #endif