Adafruit FXAS21002C Gyroscope Library
Adafruit_FXAS21002C.h
Go to the documentation of this file.
1 
20 #ifndef __FXAS21002C_H__
21 #define __FXAS21002C_H__
22 
23 #if (ARDUINO >= 100)
24 #include "Arduino.h"
25 #else
26 #include "WProgram.h"
27 #endif
28 
29 #include <Adafruit_Sensor.h>
30 #include <Wire.h>
31 
32 /*=========================================================================
33  I2C ADDRESS/BITS AND SETTINGS
34  -----------------------------------------------------------------------*/
36 // #define FXAS21002C_ADDRESS (0x21) // 0100001
38 #define FXAS21002C_ID (0xD7) // 1101 0111
39 
40 #define GYRO_SENSITIVITY_250DPS (0.0078125F) // Table 35 of datasheet
41 
42 #define GYRO_SENSITIVITY_500DPS (0.015625F)
43 
44 #define GYRO_SENSITIVITY_1000DPS (0.03125F)
45 
46 #define GYRO_SENSITIVITY_2000DPS (0.0625F)
47 /*=========================================================================*/
48 
49 /*=========================================================================
50  REGISTERS
51  -----------------------------------------------------------------------*/
55 typedef enum {
64  0x0C,
66  0x0D,
68  0x13,
70  0x14,
72 /*=========================================================================*/
73 
74 /*=========================================================================
75  OPTIONAL SPEED SETTINGS
76  -----------------------------------------------------------------------*/
80 typedef enum {
85 } gyroRange_t;
86 /*=========================================================================*/
87 
88 /*=========================================================================
89  RAW GYROSCOPE DATA TYPE
90  -----------------------------------------------------------------------*/
94 typedef struct gyroRawData_s {
95  int16_t x;
96  int16_t y;
97  int16_t z;
99 /*=========================================================================*/
100 
101 /**************************************************************************/
105 /**************************************************************************/
106 class Adafruit_FXAS21002C : public Adafruit_Sensor {
107 public:
108  Adafruit_FXAS21002C(int32_t sensorID = -1, byte addr = 0x21);
109 
110  bool begin(gyroRange_t rng = GYRO_RANGE_250DPS);
111  bool getEvent(sensors_event_t *event);
112  void getSensor(sensor_t *sensor);
113  void standby(boolean standby);
114 
117 
118 private:
119  void write8(byte reg, byte value);
120  byte read8(byte reg);
121  gyroRange_t _range;
122  int32_t _sensorID;
123  byte _sensorAddr;
124 };
125 
126 #endif
Definition: Adafruit_FXAS21002C.h:83
Definition: Adafruit_FXAS21002C.h:94
Definition: Adafruit_FXAS21002C.h:84
struct gyroRawData_s gyroRawData_t
Definition: Adafruit_FXAS21002C.h:62
Definition: Adafruit_FXAS21002C.h:59
Definition: Adafruit_FXAS21002C.h:58
Definition: Adafruit_FXAS21002C.h:82
Definition: Adafruit_FXAS21002C.h:60
gyroRegisters_t
Definition: Adafruit_FXAS21002C.h:55
int16_t x
Definition: Adafruit_FXAS21002C.h:95
Definition: Adafruit_FXAS21002C.h:81
int16_t z
Definition: Adafruit_FXAS21002C.h:97
Unified sensor driver for the Adafruit FXAS21002C breakout.
Definition: Adafruit_FXAS21002C.h:106
Definition: Adafruit_FXAS21002C.h:57
gyroRawData_t raw
Definition: Adafruit_FXAS21002C.h:116
Definition: Adafruit_FXAS21002C.h:69
Definition: Adafruit_FXAS21002C.h:67
Definition: Adafruit_FXAS21002C.h:56
gyroRange_t
Definition: Adafruit_FXAS21002C.h:80
int16_t y
Definition: Adafruit_FXAS21002C.h:96
Definition: Adafruit_FXAS21002C.h:63
Definition: Adafruit_FXAS21002C.h:61
Definition: Adafruit_FXAS21002C.h:65