Device driver for the LSM6DSL 3D accelerometer/gyroscope. More...

Detailed Description

Device driver for the LSM6DSL 3D accelerometer/gyroscope.

This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.

Files

file  lsm6dsl.h
 Device driver interface for the LSM6DSL 3D accelerometer/gyroscope.
 
file  lsm6dsl_internal.h
 Internal configuration for LSM6DSL devices.
 
file  lsm6dsl_params.h
 Default configuration for LSM6DSL devices.
 

Data Structures

struct  lsm6dsl_params_t
 LSM6DSL driver parameters. More...
 
struct  lsm6dsl_t
 LSM6DSL device descriptor. More...
 
struct  lsm6dsl_3d_data_t
 3D output data More...
 

Enumerations

enum  {
  LSM6DSL_DATA_RATE_POWER_DOWN = 0x0, LSM6DSL_DATA_RATE_1_6HZ = 0xB, LSM6DSL_DATA_RATE_12_5HZ = 0x1, LSM6DSL_DATA_RATE_26HZ = 0x2,
  LSM6DSL_DATA_RATE_52HZ = 0x3, LSM6DSL_DATA_RATE_104HZ = 0x4, LSM6DSL_DATA_RATE_208HZ = 0x5, LSM6DSL_DATA_RATE_416HZ = 0x6,
  LSM6DSL_DATA_RATE_833HZ = 0x7, LSM6DSL_DATA_RATE_1_66KHZ = 0x8, LSM6DSL_DATA_RATE_3_33KHZ = 0x9, LSM6DSL_DATA_RATE_6_66KHZ = 0xa
}
 Data rate settings.
 
enum  {
  LSM6DSL_DECIMATION_NOT_IN_FIFO = 0, LSM6DSL_DECIMATION_NO, LSM6DSL_DECIMATION_2, LSM6DSL_DECIMATION_3,
  LSM6DSL_DECIMATION_4, LSM6DSL_DECIMATION_8, LSM6DSL_DECIMATION_16, LSM6DSL_DECIMATION_32
}
 Decimation settings.
 
enum  {
  LSM6DSL_ACC_FS_2G = 0, LSM6DSL_ACC_FS_16G, LSM6DSL_ACC_FS_4G, LSM6DSL_ACC_FS_8G,
  LSM6DSL_ACC_FS_MAX
}
 Accelerometer full scale.
 
enum  {
  LSM6DSL_GYRO_FS_245DPS = 0, LSM6DSL_GYRO_FS_500DPS, LSM6DSL_GYRO_FS_1000DPS, LSM6DSL_GYRO_FS_2000DPS,
  LSM6DSL_GYRO_FS_MAX
}
 Gyroscope full scale.
 
enum  { LSM6DSL_OK = 0, LSM6DSL_ERROR_BUS, LSM6DSL_ERROR_CNF, LSM6DSL_ERROR_DEV }
 Named return values. More...
 

Functions

int lsm6dsl_init (lsm6dsl_t *dev, const lsm6dsl_params_t *params)
 Initialize a LSM6DSL device. More...
 
int lsm6dsl_read_acc (const lsm6dsl_t *dev, lsm6dsl_3d_data_t *data)
 Read accelerometer data. More...
 
int lsm6dsl_read_gyro (const lsm6dsl_t *dev, lsm6dsl_3d_data_t *data)
 Read gyroscope data. More...
 
int lsm6dsl_read_temp (const lsm6dsl_t *dev, int16_t *data)
 Read temperature data. More...
 
int lsm6dsl_acc_power_down (const lsm6dsl_t *dev)
 Power down accelerometer. More...
 
int lsm6dsl_gyro_power_down (const lsm6dsl_t *dev)
 Power down gyroscope. More...
 
int lsm6dsl_acc_power_up (const lsm6dsl_t *dev)
 Power up accelerometer. More...
 
int lsm6dsl_gyro_power_up (const lsm6dsl_t *dev)
 Power up gyroscope. More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Named return values.

Enumerator
LSM6DSL_OK 

all good

LSM6DSL_ERROR_BUS 

I2C bus error.

LSM6DSL_ERROR_CNF 

Config error.

LSM6DSL_ERROR_DEV 

device error

Definition at line 123 of file lsm6dsl.h.

Function Documentation

◆ lsm6dsl_acc_power_down()

int lsm6dsl_acc_power_down ( const lsm6dsl_t dev)

Power down accelerometer.

Parameters
[in]devdevice to power down
Returns
LSM6DSL_OK on success
< 0 on error

◆ lsm6dsl_acc_power_up()

int lsm6dsl_acc_power_up ( const lsm6dsl_t dev)

Power up accelerometer.

Parameters
[in]devdevice to power up
Returns
LSM6DSL_OK on success
< 0 on error

◆ lsm6dsl_gyro_power_down()

int lsm6dsl_gyro_power_down ( const lsm6dsl_t dev)

Power down gyroscope.

Parameters
[in]devdevice to power down
Returns
LSM6DSL_OK on success
< 0 on error

◆ lsm6dsl_gyro_power_up()

int lsm6dsl_gyro_power_up ( const lsm6dsl_t dev)

Power up gyroscope.

Parameters
[in]devdevice to power up
Returns
LSM6DSL_OK on success
< 0 on error

◆ lsm6dsl_init()

int lsm6dsl_init ( lsm6dsl_t dev,
const lsm6dsl_params_t params 
)

Initialize a LSM6DSL device.

Parameters
[out]devdevice to initialize
[in]paramsdriver parameters
Returns
LSM6DSL_OK on success
< 0 on error

◆ lsm6dsl_read_acc()

int lsm6dsl_read_acc ( const lsm6dsl_t dev,
lsm6dsl_3d_data_t data 
)

Read accelerometer data.

Parameters
[in]devdevice to read
[out]dataaccelerometer values
Returns
LSM6DSL_OK on success
< 0 on error

◆ lsm6dsl_read_gyro()

int lsm6dsl_read_gyro ( const lsm6dsl_t dev,
lsm6dsl_3d_data_t data 
)

Read gyroscope data.

Parameters
[in]devdevice to read
[out]datagyroscope values
Returns
LSM6DSL_OK on success
< 0 on error

◆ lsm6dsl_read_temp()

int lsm6dsl_read_temp ( const lsm6dsl_t dev,
int16_t *  data 
)

Read temperature data.

Note
To avoid floating point data types but still provide high resolution for temperature readings, resulting values are scale by factor 100.
Parameters
[in]devdevice to read
[out]datatemperature value, in °C x 100
Returns
LSM6DSL_OK on success
< 0 on error