StepOne / LSM6DS0

Dependents:   StepOne (store accelerometer value)

Fork of LSM6DS0 by Simone Saracino

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers lsm6ds0.h Source File

lsm6ds0.h

00001 // Library for the STMicroelectronics LSM6DS0 3D accelerometer and 3D gyroscope
00002 
00003 // Define to prevent recursive inclusion -------------------------------------
00004 #ifndef __LSM6DS0_H
00005 #define __LSM6DS0_H
00006 
00007 #include "mbed.h"
00008 
00009 
00010 /******************************************************************************/
00011 /*********** 3D ACCELEROMETER AND 3D GYROSCOPE REGISTER MAPPING  **************/
00012 /******************************************************************************/
00013 
00014 #define  LSM6DS0_ACC_SENS_2G                     ((float)0.061)         // Accelerometer sensitivity with 2 G full scale [mg / LSB]
00015 #define  LSM6DS0_ACC_SENS_4G                     ((float)0.122)         // Accelerometer sensitivity with 4 G full scale [mg / LSB]
00016 #define  LSM6DS0_ACC_SENS_8G                     ((float)0.244)         // Accelerometer sensitivity with 8 G full scale [mg / LSB]
00017 #define  LSM6DS0_ACC_SENS_16G                    ((float)0.732)          // Accelerometer sensitivity with 16 G full scale [mg / LSB]
00018 
00019 #define  LSM6DS0_GYRO_SENS_245DPS                ((float)8.75f)         //
00020 #define  LSM6DS0_GYRO_SENS_500DPS                ((float)17.50f)        // Gyroscope sensitivity with 500 dps full scale [mdps / LSB]
00021 #define  LSM6DS0_GYRO_SENS_2000DPS               ((float)70f)           // Gyroscope sensitivity with 2000 dps full scale [mdps / LSB]
00022 
00023 #define  LSM6DS0_GYRO_SENS_245DPS                ((float)8.75f)         //Gyroscope sensitivity with 245 dps full scale [mdps / LSB]
00024 #define  LSM6DS0_GYRO_SENS_500DPS                ((float)17.50f)        // Gyroscope sensitivity with 500 dps full scale [mdps / LSB]
00025 #define  LSM6DS0_GYRO_SENS_2000DPS               ((float)70f)           // Gyroscope sensitivity with 2000 dps full scale [mdps / LSB]
00026 
00027 // LSM6DS0 register names
00028 
00029 /******************************************************************************/
00030 /*                                                                            */
00031 /*                        LSM6DS0 on board MEMS                               */
00032 /*                                                                            */
00033 /******************************************************************************/
00034 /*****************  Bit definition for I2C/SPI communication  *****************/
00035 #define  LSM6DS0_ADDRESS                         0xD6
00036 #define  LSM6DS0_SUB                             ((uint8_t)0x7F)            // SUB[6:0] Sub-registers address Mask
00037 #define  LSM6DS0_SUB_0                           ((uint8_t)0x01)            // bit 0
00038 #define  LSM6DS0_SUB_1                           ((uint8_t)0x02)            // bit 1
00039 #define  LSM6DS0_SUB_2                           ((uint8_t)0x08)            // bit 3
00040 #define  LSM6DS0_SUB_4                           ((uint8_t)0x10)            // bit 4
00041 #define  LSM6DS0_SUB_5                           ((uint8_t)0x20)            // bit 5
00042 #define  LSM6DS0_SUB_6                           ((uint8_t)0x40)            // bit 6
00043 
00044 #define  LSM6DS0_SUB_MSB                         ((uint8_t)0x80)            // Multiple data read\write bit
00045 
00046 /*****************  Bit definition for Registers Addresses  *******************/
00047 #define  LSM6DS0_SUB_ACT_THS                     ((uint8_t)0x04)            // Activity threshold register
00048 #define  LSM6DS0_SUB_ACT_DUR                     ((uint8_t)0x05)            // Inactivity duration register
00049 #define  LSM6DS0_SUB_INT_GEN_CFG_XL              ((uint8_t)0x06)            // Accelerometer interrupt generator configuration register
00050 #define  LSM6DS0_SUB_INT_GEN_THS_X_XL            ((uint8_t)0x07)            // Accelerometer X-axis interrupt threshold register
00051 #define  LSM6DS0_SUB_INT_GEN_THS_Y_XL            ((uint8_t)0x08)            // Accelerometer Y-axis interrupt threshold register
00052 #define  LSM6DS0_SUB_INT_GEN_THS_Z_XL            ((uint8_t)0x09)            // Accelerometer Z-axis interrupt threshold register
00053 #define  LSM6DS0_SUB_INT_GEN_DUR_XL              ((uint8_t)0x0A)            // Accelerometer interrupt duration register
00054 #define  LSM6DS0_SUB_REFERENCE_G                 ((uint8_t)0x0B)            // Gyroscope reference value register for digital high-pass filter
00055 #define  LSM6DS0_SUB_INT_CTRL                    ((uint8_t)0x0C)            // INT pin control register
00056 #define  LSM6DS0_SUB_WHO_AM_I                    ((uint8_t)0x0F)            // Who_AM_I register
00057 #define  LSM6DS0_SUB_CTRL_REG1_G                 ((uint8_t)0x10)            // Gyroscope control register 1
00058 #define  LSM6DS0_SUB_CTRL_REG2_G                 ((uint8_t)0x11)            // Gyroscope control register 2
00059 #define  LSM6DS0_SUB_CTRL_REG3_G                 ((uint8_t)0x12)            // Gyroscope control register 3
00060 #define  LSM6DS0_SUB_ORIENT_CFG_G                ((uint8_t)0x13)            // Gyroscope sign and orientation register
00061 #define  LSM6DS0_SUB_INT_GEN_SRC_G               ((uint8_t)0x14)            // Gyroscope interrupt source register
00062 #define  LSM6DS0_SUB_OUT_TEMP_L                  ((uint8_t)0x15)            // Temperature data output low register
00063 #define  LSM6DS0_SUB_OUT_TEMP_H                  ((uint8_t)0x16)            // Temperature data output high register
00064 #define  LSM6DS0_SUB_STATUS_REG1                 ((uint8_t)0x17)            // Status register 1
00065 #define  LSM6DS0_SUB_OUT_X_L_G                   ((uint8_t)0x18)            // Gyroscope X-axis low output register
00066 #define  LSM6DS0_SUB_OUT_X_H_G                   ((uint8_t)0x19)            // Gyroscope X-axis high output register
00067 #define  LSM6DS0_SUB_OUT_Y_L_G                   ((uint8_t)0x1A)            // Gyroscope Y-axis low output register
00068 #define  LSM6DS0_SUB_OUT_Y_H_G                   ((uint8_t)0x1B)            // Gyroscope Y-axis high output register
00069 #define  LSM6DS0_SUB_OUT_Z_L_G                   ((uint8_t)0x1C)            // Gyroscope Z-axis low output register
00070 #define  LSM6DS0_SUB_OUT_Z_H_G                   ((uint8_t)0x1D)            // Gyroscope Z-axis high output register
00071 #define  LSM6DS0_SUB_CTRL_REG4                   ((uint8_t)0x1E)            // Control register 4
00072 #define  LSM6DS0_SUB_CTRL_REG5_XL                ((uint8_t)0x1F)            // Accelerometer Control Register 5
00073 #define  LSM6DS0_SUB_CTRL_REG6_XL                ((uint8_t)0x20)            // Accelerometer Control Register 6
00074 #define  LSM6DS0_SUB_CTRL_REG7_XL                ((uint8_t)0x21)            // Accelerometer Control Register 7
00075 #define  LSM6DS0_SUB_CTRL_REG8                   ((uint8_t)0x22)            // Control register 8
00076 #define  LSM6DS0_SUB_CTRL_REG9                   ((uint8_t)0x23)            // Control register 9
00077 #define  LSM6DS0_SUB_CTRL_REG10                  ((uint8_t)0x24)            // Control register 10
00078 #define  LSM6DS0_SUB_INT_GEN_SRC_XL              ((uint8_t)0x26)            // Accelerometer interrupt source register
00079 #define  LSM6DS0_SUB_STATUS_REG2                 ((uint8_t)0x27)            // Status register
00080 #define  LSM6DS0_SUB_OUT_X_L_XL                  ((uint8_t)0x28)            // Accelerometer X-axis low output register
00081 #define  LSM6DS0_SUB_OUT_X_H_XL                  ((uint8_t)0x29)            // Accelerometer X-axis high output register
00082 #define  LSM6DS0_SUB_OUT_Y_L_XL                  ((uint8_t)0x2A)            // Accelerometer Y-axis low output register
00083 #define  LSM6DS0_SUB_OUT_Y_H_XL                  ((uint8_t)0x2B)            // Accelerometer Y-axis high output register
00084 #define  LSM6DS0_SUB_OUT_Z_L_XL                  ((uint8_t)0x2C)            // Accelerometer Z-axis low output register
00085 #define  LSM6DS0_SUB_OUT_Z_H_XL                  ((uint8_t)0x2D)            // Accelerometer Z-axis high output register
00086 #define  LSM6DS0_SUB_FIFO_CTRL                   ((uint8_t)0x2E)            // FIFO control register
00087 #define  LSM6DS0_SUB_FIFO_SRC                    ((uint8_t)0x2F)            // FIFO status control register
00088 #define  LSM6DS0_SUB_INT_GEN_CFG_G               ((uint8_t)0x30)            // Gyroscope interrupt generator configuration register
00089 #define  LSM6DS0_SUB_INT_GEN_THS_XH_G            ((uint8_t)0x31)            // Gyroscope X-axis low interrupt generator threshold registers
00090 #define  LSM6DS0_SUB_INT_GEN_THS_XL_G            ((uint8_t)0x32)            // Gyroscope X-axis high interrupt generator threshold registers
00091 #define  LSM6DS0_SUB_INT_GEN_THS_YH_G            ((uint8_t)0x33)            // Gyroscope Y-axis low interrupt generator threshold registers
00092 #define  LSM6DS0_SUB_INT_GEN_THS_YL_G            ((uint8_t)0x34)            // Gyroscope Y-axis high interrupt generator threshold registers
00093 #define  LSM6DS0_SUB_INT_GEN_THS_ZH_G            ((uint8_t)0x35)            // Gyroscope Z-axis low interrupt generator threshold registers
00094 #define  LSM6DS0_SUB_INT_GEN_THS_ZL_G            ((uint8_t)0x36)            // Gyroscope Z-axis high interrupt generator threshold registers
00095 #define  LSM6DS0_SUB_INT_GEN_DUR_G               ((uint8_t)0x37)            // Gyroscope interrupt generator duration register
00096 
00097 #define BIT_0                                    0
00098 #define BIT_1                                    1
00099 #define BIT_2                                    2
00100 #define BIT_3                                    3
00101 #define BIT_4                                    4
00102 #define BIT_5                                    5
00103 #define BIT_6                                    6
00104 #define BIT_7                                    7
00105 
00106 #define FIFO_length_by_five                      160                        //The length of 5 FIFO depth 
00107 
00108 // Generic LSM6DS0 data structures and types
00109 
00110 // FIFO mode
00111 typedef enum {
00112     LSM6DS0_FIFO_mode_BYPASS = 0x00,                    // LSM6DS0 work in BYPASS mode
00113     LSM6DS0_FIFO_mode_FIFO = 0x20,                      // LSM6DS0 work in FIFO mode
00114     LSM6DS0_FIFO_mode_CONTINUOUS = 0xC0,                // LSM6DS0 work in CONTINUOUS mode
00115     LSM6DS0_FIFO_mode_CONTINUOUS_BYPASS = 0x60,         // LSM6DS0 work in CONTINUOUS-to-BYPAS mode
00116     LSM6DS0_FIFO_mode_BYPASS_CONTINUOUS = 0x80,         // LSM6DS0 work in BYPASS-to-CONTINUOUS mode
00117 }LSM6DS0_FIFO_mode_t;
00118 
00119 
00120 // Accelerometer and Gyroscope Slave Address
00121 typedef enum {
00122     LSM6DS0_SAD_GND = 0x6A,                             // LSM6DS0 Slave Address when SA1 is to GND
00123     LSM6DS0_SAD_VCC = 0x6B                              // LSM6DS0 Slave Address when SA1 is to VCC
00124 }LSM6DS0_SAD_t;
00125 
00126 // Accelerometer and Gyroscope Block Data Update
00127 typedef enum
00128 {
00129     LSM6DS0_BDU_CONTINOUS = 0x00,                       // Continuos Update
00130     LSM6DS0_BDU_BLOCKED   = 0x40                        // Single Update: output registers not updated until MSB and LSB reading
00131 }LSM6DS0_BDU_t;
00132 
00133 // Accelerometer and Gyroscope Endianness
00134 typedef enum
00135 {
00136     LSM6DS0_END_LITTLE = 0x00,                          // Little Endian: data LSB @ lower address
00137     LSM6DS0_END_BIG    = 0x20                           // Big Endian: data MSB @ lower address
00138 }LSM6DS0_END_t;
00139 
00140 // Accelerometer data structures and types
00141 
00142 // Accelerometer Decimation Mode
00143 typedef enum {
00144     LSM6DS0_ACC_DEC_DISABLED = 0x00,                    // NO decimation
00145     LSM6DS0_ACC_DEC_X2       = 0x40,                    // Decimation update every 2 sample
00146     LSM6DS0_ACC_DEC_X4       = 0x80,                    // Decimation update every 4 sample
00147     LSM6DS0_ACC_DEC_X8       = 0xC0                     // Decimation update every 8 sample
00148 }LSM6DS0_ACC_DEC_t;
00149 
00150 // Accelerometer Axes Enabling
00151 typedef enum{
00152     LSM6DS0_ACC_AE_DISABLED = 0x00,                     // Axes all disabled
00153     LSM6DS0_ACC_AE_X        = 0x08,                     // Only X-axis enabled
00154     LSM6DS0_ACC_AE_Y        = 0x10,                     // Only Y-axis enabled
00155     LSM6DS0_ACC_AE_XY       = 0x18,                     // X & Y axes enabled
00156     LSM6DS0_ACC_AE_Z        = 0x20,                     // Only Z-axis enabled
00157     LSM6DS0_ACC_AE_XZ       = 0x28,                     // X & Z axes enabled
00158     LSM6DS0_ACC_AE_YZ       = 0x30,                     // Y & Z axes enabled
00159     LSM6DS0_ACC_AE_XYZ      = 0x38                      // All axes enabled
00160 }LSM6DS0_ACC_AE_t;
00161 
00162 // Accelerometer Output Data Rate
00163 typedef enum {
00164     LSM6DS0_ACC_ODR_PD    = 0x00,                       // Power down
00165     LSM6DS0_ACC_ODR_10Hz  = 0x20,                       // Output Data Rate = 10 Hz
00166     LSM6DS0_ACC_ODR_50Hz  = 0x40,                       // Output Data Rate = 50 Hz
00167     LSM6DS0_ACC_ODR_119Hz = 0x60,                       // Output Data Rate = 119 Hz
00168     LSM6DS0_ACC_ODR_238Hz = 0x80,                       // Output Data Rate = 238 Hz
00169     LSM6DS0_ACC_ODR_476Hz = 0xA0,                       // Output Data Rate = 476 Hz
00170     LSM6DS0_ACC_ODR_952Hz = 0xC0                        // Output Data Rate = 952 Hz
00171 }LSM6DS0_ACC_ODR_t;
00172 
00173 // Accelerometer Full Scale
00174 typedef enum {
00175     LSM6DS0_ACC_FS_2G  = 0x00,                          // 2 g m/s^2
00176     LSM6DS0_ACC_FS_4G  = 0x10,                          // 4 g m/s^2
00177     LSM6DS0_ACC_FS_8G  = 0x18,                          // 8 g m/s^2
00178     LSM6DS0_ACC_FS_16G = 0x08                           // 16 g m/s^2
00179 }LSM6DS0_ACC_FS_t;
00180 
00181 // Accelerometer Antialiasing filter Bandwidth Selection
00182 typedef enum {
00183     LSM6DS0_ACC_BW_408Hz    = 0x00,                     // AA filter bandwidth = 408 Hz
00184     LSM6DS0_ACC_BW_211Hz    = 0x01,                     // AA filter bandwidth = 211 Hz
00185     LSM6DS0_ACC_BW_105Hz    = 0x02,                     // AA filter bandwidth = 105 Hz
00186     LSM6DS0_ACC_BW_50Hz     = 0x03,                     // AA filter bandwidth = 50 Hz
00187     LSM6DS0_ACC_BW_ACCORDED = 0x04,                     // AA filter bandwidth chosen by ODR selection
00188 }LSM6DS0_ACC_BW_t;
00189 
00190 // Accelerometer High Resolution mode
00191 typedef enum
00192 {
00193     LSM6DS0_ACC_HR_Disabled = 0x00,                     // High resolution output mode disabled, FDS bypassed
00194     LSM6DS0_ACC_HR_EN_9     = 0xC4,                     // High resolution output mode enabled, LP cutoff = ODR/9, FDS enabled
00195     LSM6DS0_ACC_HR_EN_50    = 0x84,                     // High resolution output mode enabled, LP cutoff = ODR/50, FDS enabled
00196     LSM6DS0_ACC_HR_EN_100   = 0xA4,                     // High resolution output mode enabled, LP cutoff = ODR/100, FDS enabled
00197     LSM6DS0_ACC_HR_EN_400   = 0xE4,                     // High resolution output mode enabled, LP cutoff = ODR/400, FDS enabled
00198 }LSM6DS0_ACC_HR_t;
00199 
00200 // HP filter for interrupt
00201 typedef enum
00202 {
00203     LSM6DS0_ACC_HPIS1_BYPASSED = 0x00,                  // High-pass filter bypassed
00204     LSM6DS0_ACC_HPIS1_ENABLED  = 0x01                   // High-pass filter enabled for accelerometer interrupt function on interrupt
00205 }LSM6DS0_ACC_HPIS1_t;
00206 
00207 // Accelerometer configuration structure.
00208 typedef struct {
00209     LSM6DS0_SAD_t       slaveaddress;       // LSM6DS0 Slave Address
00210     LSM6DS0_ACC_DEC_t   decimation;         // Accelerometer Decimation Mode
00211     LSM6DS0_ACC_ODR_t   outputdatarate;     // Accelerometer Output Data Rate
00212     LSM6DS0_ACC_BW_t    bandwidth;          // Accelerometer Antialiasing filter Bandwidth Selection
00213     LSM6DS0_ACC_FS_t    fullscale;          // Accelerometer Full Scale
00214     LSM6DS0_ACC_AE_t    axesenabling;       // Accelerometer Axes Enabling
00215     LSM6DS0_ACC_HR_t    highresmode;        // Accelerometer High Resolution mode
00216     LSM6DS0_ACC_HPIS1_t hpfirq;             // HP filter for interrupt
00217     LSM6DS0_END_t       endianess;          // LSM6DS0 Endianness
00218     LSM6DS0_BDU_t       blockdataupdate;    // LSM6DS0 Block Data Update
00219 } LSM6DS0_ACC_Config;
00220 
00221 
00222 // Gyroscope data structures and types
00223 
00224 // Gyroscope Output Data Rate
00225 typedef enum {
00226     LSM6DS0_GYRO_ODR_PD             = 0x00,             // Power down
00227     LSM6DS0_GYRO_ODR_14_9Hz_CO_5Hz  = 0x20,             // Output Data Rate = 14.9 Hz, CutOff = 5Hz
00228     LSM6DS0_GYRO_ODR_59_5Hz_CO_16Hz = 0x40,             // Output Data Rate = 59.5 Hz, CutOff = 16Hz
00229     LSM6DS0_GYRO_ODR_119Hz_CO_14Hz  = 0x60,             // Output Data Rate = 119 Hz, CutOff = 14Hz
00230     LSM6DS0_GYRO_ODR_119Hz_CO_31Hz  = 0x61,             // Output Data Rate = 119 Hz, CutOff = 31Hz
00231     LSM6DS0_GYRO_ODR_238Hz_CO_14Hz  = 0x80,             // Output Data Rate = 238 Hz, CutOff = 14Hz
00232     LSM6DS0_GYRO_ODR_238Hz_CO_29Hz  = 0x81,             // Output Data Rate = 328 Hz, CutOff = 29Hz
00233     LSM6DS0_GYRO_ODR_238Hz_CO_63Hz  = 0x82,             // Output Data Rate = 238 Hz, CutOff = 63Hz
00234     LSM6DS0_GYRO_ODR_238Hz_CO_78Hz  = 0x83,             // Output Data Rate = 476 Hz, CutOff = 78Hz
00235     LSM6DS0_GYRO_ODR_476Hz_CO_21Hz  = 0xA0,             // Output Data Rate = 476 Hz, CutOff = 21Hz
00236     LSM6DS0_GYRO_ODR_476Hz_CO_28Hz  = 0xA1,             // Output Data Rate = 238 Hz, CutOff = 28Hz
00237     LSM6DS0_GYRO_ODR_476Hz_CO_57Hz  = 0xA2,             // Output Data Rate = 476 Hz, CutOff = 57Hz
00238     LSM6DS0_GYRO_ODR_476Hz_CO_100Hz = 0xA3,             // Output Data Rate = 476 Hz, CutOff = 100Hz
00239     LSM6DS0_GYRO_ODR_952Hz_CO_33Hz  = 0xC0,             // Output Data Rate = 952 Hz, CutOff = 33Hz
00240     LSM6DS0_GYRO_ODR_952Hz_CO_40Hz  = 0xC1,             // Output Data Rate = 952 Hz, CutOff = 40Hz
00241     LSM6DS0_GYRO_ODR_952Hz_CO_58Hz  = 0xC2,             // Output Data Rate = 952 Hz, CutOff = 58Hz
00242     LSM6DS0_GYRO_ODR_952Hz_CO_100Hz = 0xC3              // Output Data Rate = 952 Hz, CutOff = 100Hz
00243 }LSM6DS0_GYRO_ODR_t;
00244 
00245 // Gyroscope Full Scale
00246 typedef enum {
00247     LSM6DS0_GYRO_FS_245DSP  = 0x00,                     // 245 degrees per second
00248     LSM6DS0_GYRO_FS_500DSP  = 0x08,                     // 500 degrees per second
00249     LSM6DS0_GYRO_FS_2000DSP = 0x18                      // 2000 degrees per second
00250 }LSM6DS0_GYRO_FS_t;
00251 
00252 // Gyroscope Output Selection
00253 typedef enum {
00254     LSM6DS0_GYRO_OUT_SEL_BYPASS    = 0x00,              // Output not filtered
00255     LSM6DS0_GYRO_OUT_SEL_FILTERED  = 0x01,              // Output filtered
00256 }LSM6DS0_GYRO_OUT_SEL_t;
00257 
00258 // Gyroscope Interrupt Selection
00259 typedef enum {
00260     LSM6DS0_GYRO_INT_SEL_BYPASS    = 0x00,              // Interrupt generator signal not filtered
00261     LSM6DS0_GYRO_INT_SEL_FILTERED  = 0x08,              // Interrupt generator signal filtered
00262 }LSM6DS0_GYRO_INT_SEL_t;
00263 
00264 // Gyroscope Low Power Mode
00265 typedef enum {
00266     LSM6DS0_GYRO_LP_MODE_HIGH_PERFORMANCE = 0x00,       // High performance
00267     LSM6DS0_GYRO_LP_MODE_LOW_POWER        = 0x80,       // Low power
00268 }LSM6DS0_GYRO_LP_MODE_t;
00269 
00270 // Gyroscope High Pass Filter Cutoff Selection
00271 typedef enum {
00272     LSM6DS0_GYRO_HPCF_DISABLED = 0x00,                  // HP filter disabled
00273     LSM6DS0_GYRO_HPCF_0        = 0x40,                  // Config 0 refer to table 48 of DOcID025604 Rev 3
00274     LSM6DS0_GYRO_HPCF_1        = 0x41,                  // Config 1 refer to table 48 of DOcID025604 Rev 3
00275     LSM6DS0_GYRO_HPCF_2        = 0x42,                  // Config 2 refer to table 48 of DOcID025604 Rev 3
00276     LSM6DS0_GYRO_HPCF_3        = 0x43,                  // Config 3 refer to table 48 of DOcID025604 Rev 3
00277     LSM6DS0_GYRO_HPCF_4        = 0x44,                  // Config 4 refer to table 48 of DOcID025604 Rev 3
00278     LSM6DS0_GYRO_HPCF_5        = 0x45,                  // Config 5 refer to table 48 of DOcID025604 Rev 3
00279     LSM6DS0_GYRO_HPCF_6        = 0x46,                  // Config 6 refer to table 48 of DOcID025604 Rev 3
00280     LSM6DS0_GYRO_HPCF_7        = 0x47,                  // Config 7 refer to table 48 of DOcID025604 Rev 3
00281     LSM6DS0_GYRO_HPCF_8        = 0x48,                  // Config 8 refer to table 48 of DOcID025604 Rev 3
00282     LSM6DS0_GYRO_HPCF_9        = 0x49,                  // Config 9 refer to table 48 of DOcID025604 Rev 3
00283     LSM6DS0_GYRO_HPCF_10       = 0x4A                   // Config 10 refer to table 48 of DOcID025604 Rev 3
00284 }LSM6DS0_GYRO_HPCF_t;
00285 
00286 // Gyroscope Axes Enabling
00287 typedef enum{
00288     LSM6DS0_GYRO_AE_DISABLED = 0x00,                    // Axes all disabled
00289     LSM6DS0_GYRO_AE_X        = 0x08,                    // Only X-axis enabled
00290     LSM6DS0_GYRO_AE_Y        = 0x10,                    // Only Y-axis enabled
00291     LSM6DS0_GYRO_AE_XY       = 0x18,                    // X & Y axes enabled
00292     LSM6DS0_GYRO_AE_Z        = 0x20,                    // Only Z-axis enabled
00293     LSM6DS0_GYRO_AE_XZ       = 0x28,                    // X & Z axes enabled
00294     LSM6DS0_GYRO_AE_YZ       = 0x30,                    // Y & Z axes enabled
00295     LSM6DS0_GYRO_AE_XYZ      = 0x38                     // All axes enabled
00296 }LSM6DS0_GYRO_AE_t;
00297 
00298 // Gyroscope Decimation Mode
00299 typedef enum {
00300     LSM6DS0_GYRO_DEC_DISABLED = 0x00,                   // NO decimation
00301     LSM6DS0_GYRO_DEC_X2       = 0x40,                   // Decimation update every 2 sample
00302     LSM6DS0_GYRO_DEC_X4       = 0x80,                   // Decimation update every 4 sample
00303     LSM6DS0_GYRO_DEC_X8       = 0xC0                    // Decimation update every 8 sample
00304 }LSM6DS0_GYRO_DEC_t;
00305 
00306 //Gyroscope Sleep Mode
00307 typedef enum {
00308     LSM6DS0_GYRO_SLP_DISABLED = 0x00,                   // Gyroscope sleep mode disabled
00309     LSM6DS0_GYRO_SLP_ENABLED  = 0x40                    // Gyroscope sleep mode enabled
00310 }LSM6DS0_GYRO_SLP_t;
00311 
00312 // Gyroscope configuration structure
00313 typedef struct {
00314     LSM6DS0_SAD_t   slaveaddress;           //LSM6DS0 Slave Address
00315     LSM6DS0_GYRO_ODR_t   outputdatarate;    // Gyroscope Output Data Rate
00316     LSM6DS0_GYRO_FS_t    fullscale;         // Gyroscope Full Scale
00317     LSM6DS0_GYRO_OUT_SEL_t outputselect;    // Gyroscope Output Selection
00318     LSM6DS0_GYRO_INT_SEL_t irqselect;       // Gyroscope Interrupt Selection
00319     LSM6DS0_GYRO_LP_MODE_t lowpowermode;    // Gyroscope Low Power Mode
00320     LSM6DS0_GYRO_HPCF_t HPCfrequency;       // Gyroscope High Pass Filter Cutoff Selection
00321     LSM6DS0_GYRO_AE_t axesenabling;         // Gyroscope Axes Enabling
00322     LSM6DS0_GYRO_DEC_t decimation;          // Gyroscope Decimation Mode
00323     LSM6DS0_END_t   endianess;              // LSM6DS0 Endianness
00324     LSM6DS0_BDU_t   blockdataupdate;        // LSM6DS0 Block Data Update
00325 } LSM6DS0_GYRO_Config;
00326 
00327 typedef struct{
00328     int16_t x;
00329     int16_t y;
00330     int16_t z;
00331 } xl_output;
00332 
00333 class LSM6DS0{
00334 public:
00335 
00336     
00337     /* Public Methods */
00338     
00339     void setFIFO(LSM6DS0_FIFO_mode_t work_mode);
00340     void getFIFO(void);
00341     void resetFIFO(void);
00342     void Init(LSM6DS0_ACC_ODR_t odr, LSM6DS0_ACC_HR_t high_res, LSM6DS0_FIFO_mode_t work_mode);
00343     float getSensitivity(void);
00344     void LSM6DS0_reset(void);
00345     void storeFIFO(int *offset, xl_output *data_FIFO);
00346     void computeValue(xl_output *data_FIFO);
00347     void printValue(xl_output *data_FIFO);
00348     void printReg(void);
00349     
00350     
00351 };
00352 #endif