Needed for FXAS21000 NXP gyroscope

Fork of FXAS21000 by Jim Carver

Committer:
JimCarver
Date:
Sat Apr 19 00:10:49 2014 +0000
Revision:
0:4cfc774d6d85
Child:
1:88a036a417bf
Improved version, added getWhoAmI() and readXYXraw()

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JimCarver 0:4cfc774d6d85 1 #ifndef FXAS21000_H
JimCarver 0:4cfc774d6d85 2 #define FXAS21000_H
JimCarver 0:4cfc774d6d85 3
JimCarver 0:4cfc774d6d85 4 #include "mbed.h"
JimCarver 0:4cfc774d6d85 5
JimCarver 0:4cfc774d6d85 6
JimCarver 0:4cfc774d6d85 7 // MMA8652 Slave Address
JimCarver 0:4cfc774d6d85 8 #define FXAS21000_SLAVE_ADDR 0x40
JimCarver 0:4cfc774d6d85 9
JimCarver 0:4cfc774d6d85 10 // MMA8652 internal register addresses
JimCarver 0:4cfc774d6d85 11 #define FXAS21000_STATUS 0x00
JimCarver 0:4cfc774d6d85 12 #define FXAS21000_WHOAMI 0x0C
JimCarver 0:4cfc774d6d85 13 #define FXAS21000_XYZ_DATA_CFG 0x0E
JimCarver 0:4cfc774d6d85 14 #define FXAS21000_CTRL_REG0 0x0D
JimCarver 0:4cfc774d6d85 15 #define FXAS21000_CTRL_REG1 0x13
JimCarver 0:4cfc774d6d85 16 #define FXAS21000_WHOAMI_VAL 0xD1
JimCarver 0:4cfc774d6d85 17
JimCarver 0:4cfc774d6d85 18 class FXAS21000
JimCarver 0:4cfc774d6d85 19 {
JimCarver 0:4cfc774d6d85 20 public:
JimCarver 0:4cfc774d6d85 21 /**
JimCarver 0:4cfc774d6d85 22 * FXAS21000 constructor
JimCarver 0:4cfc774d6d85 23 *
JimCarver 0:4cfc774d6d85 24 * @param sda SDA pin
JimCarver 0:4cfc774d6d85 25 * @param sdl SCL pin
JimCarver 0:4cfc774d6d85 26 *
JimCarver 0:4cfc774d6d85 27 */
JimCarver 0:4cfc774d6d85 28 FXAS21000(PinName sda, PinName scl);
JimCarver 0:4cfc774d6d85 29
JimCarver 0:4cfc774d6d85 30
JimCarver 0:4cfc774d6d85 31 /**
JimCarver 0:4cfc774d6d85 32 * Get the Gyro values
JimCarver 0:4cfc774d6d85 33 * Result is floating point degrees / second
JimCarver 0:4cfc774d6d85 34 *
JimCarver 0:4cfc774d6d85 35 * @param floating point array where the results will be placed
JimCarver 0:4cfc774d6d85 36 */
JimCarver 0:4cfc774d6d85 37 void ReadXYZ(float * a);
JimCarver 0:4cfc774d6d85 38
JimCarver 0:4cfc774d6d85 39
JimCarver 0:4cfc774d6d85 40 /**
JimCarver 0:4cfc774d6d85 41 * Get the Gyro values
JimCarver 0:4cfc774d6d85 42 * Result is signed 16 bit value
JimCarver 0:4cfc774d6d85 43 *
JimCarver 0:4cfc774d6d85 44 * @param int16_t point array where the results will be placed
JimCarver 0:4cfc774d6d85 45 */
JimCarver 0:4cfc774d6d85 46 void ReadXYZraw(int16_t * t);
JimCarver 0:4cfc774d6d85 47
JimCarver 0:4cfc774d6d85 48
JimCarver 0:4cfc774d6d85 49 /**
JimCarver 0:4cfc774d6d85 50 * Get the value of the WHO_AM_I register
JimCarver 0:4cfc774d6d85 51 *
JimCarver 0:4cfc774d6d85 52 * @returns DEVICE_ID value == 0xD1
JimCarver 0:4cfc774d6d85 53 */
JimCarver 0:4cfc774d6d85 54 //char getWhoAmI();
JimCarver 0:4cfc774d6d85 55 char getWhoAmI(void);
JimCarver 0:4cfc774d6d85 56
JimCarver 0:4cfc774d6d85 57 private:
JimCarver 0:4cfc774d6d85 58
JimCarver 0:4cfc774d6d85 59 I2C _i2c;
JimCarver 0:4cfc774d6d85 60 /** Set the device in active mode
JimCarver 0:4cfc774d6d85 61 */
JimCarver 0:4cfc774d6d85 62 void begin( void);
JimCarver 0:4cfc774d6d85 63
JimCarver 0:4cfc774d6d85 64 void RegRead( char reg, char * d, int len);
JimCarver 0:4cfc774d6d85 65
JimCarver 0:4cfc774d6d85 66
JimCarver 0:4cfc774d6d85 67 };
JimCarver 0:4cfc774d6d85 68
JimCarver 0:4cfc774d6d85 69 #endif