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 #include <Adafruit_BusIO_Register.h>
24 #include <Adafruit_I2CDevice.h>
25 #include <Adafruit_Sensor.h>
26 #include <Arduino.h>
27 #include <Wire.h>
28 
29 /*=========================================================================
30  I2C ADDRESS/BITS AND SETTINGS
31  -----------------------------------------------------------------------*/
33 // #define FXAS21002C_ADDRESS (0x21) // 0100001
35 #define FXAS21002C_ID (0xD7) // 1101 0111
36 
37 #define GYRO_SENSITIVITY_250DPS (0.0078125F) // Table 35 of datasheet
38 
39 #define GYRO_SENSITIVITY_500DPS (0.015625F)
40 
41 #define GYRO_SENSITIVITY_1000DPS (0.03125F)
42 
43 #define GYRO_SENSITIVITY_2000DPS (0.0625F)
44 /*=========================================================================*/
45 
46 /*=========================================================================
47  REGISTERS
48  -----------------------------------------------------------------------*/
52 typedef enum {
61  0x0C,
63  0x0D,
65  0x13,
67  0x14,
69 /*=========================================================================*/
70 
71 /*=========================================================================
72  OPTIONAL SPEED SETTINGS
73  -----------------------------------------------------------------------*/
77 typedef enum {
82 } gyroRange_t;
83 /*=========================================================================*/
84 
85 /*=========================================================================
86  RAW GYROSCOPE DATA TYPE
87  -----------------------------------------------------------------------*/
91 typedef struct gyroRawData_s {
92  int16_t x;
93  int16_t y;
94  int16_t z;
96 /*=========================================================================*/
97 
98 /**************************************************************************/
102 /**************************************************************************/
103 class Adafruit_FXAS21002C : public Adafruit_Sensor {
104 public:
105  Adafruit_FXAS21002C(int32_t sensorID = -1);
107  bool begin(uint8_t addr = 0x21, TwoWire *wire = &Wire);
108  bool getEvent(sensors_event_t *event);
109  void getSensor(sensor_t *sensor);
110  void standby(boolean standby);
111 
112  void setRange(gyroRange_t range);
113  gyroRange_t getRange();
115 
116 protected:
117  Adafruit_I2CDevice *i2c_dev = NULL;
118 
119 private:
120  bool initialize();
121  gyroRange_t _range;
122  int32_t _sensorID;
123 };
124 
125 #endif
Definition: Adafruit_FXAS21002C.h:80
Definition: Adafruit_FXAS21002C.h:91
Definition: Adafruit_FXAS21002C.h:81
struct gyroRawData_s gyroRawData_t
Definition: Adafruit_FXAS21002C.h:59
Definition: Adafruit_FXAS21002C.h:56
Definition: Adafruit_FXAS21002C.h:55
Definition: Adafruit_FXAS21002C.h:79
Definition: Adafruit_FXAS21002C.h:57
gyroRegisters_t
Definition: Adafruit_FXAS21002C.h:52
int16_t x
Definition: Adafruit_FXAS21002C.h:92
Definition: Adafruit_FXAS21002C.h:78
int16_t z
Definition: Adafruit_FXAS21002C.h:94
Unified sensor driver for the Adafruit FXAS21002C breakout.
Definition: Adafruit_FXAS21002C.h:103
Definition: Adafruit_FXAS21002C.h:54
gyroRawData_t raw
Raw gyroscope values from last sensor read.
Definition: Adafruit_FXAS21002C.h:114
Definition: Adafruit_FXAS21002C.h:66
Definition: Adafruit_FXAS21002C.h:64
Definition: Adafruit_FXAS21002C.h:53
gyroRange_t
Definition: Adafruit_FXAS21002C.h:77
int16_t y
Definition: Adafruit_FXAS21002C.h:93
Definition: Adafruit_FXAS21002C.h:60
Definition: Adafruit_FXAS21002C.h:58
Definition: Adafruit_FXAS21002C.h:62