Interface definition for the STM LIS2DH12 accelerometer. More...

Detailed Description

Interface definition for the STM LIS2DH12 accelerometer.

Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de

Definition in file lis2dh12.h.

#include <stdint.h>
#include <stdbool.h>
#include "saul.h"
#include "lis2dh12_registers.h"
#include "periph/gpio.h"
#include "periph/i2c.h"
+ Include dependency graph for lis2dh12.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lis2dh12_params_t
 LIS2DH12 configuration parameters. More...
 
struct  lis2dh12_highpass_t
 LIS2DH12 high pass config values. More...
 
struct  lis2dh12_click_t
 LIS2DH12 click config values. More...
 
struct  lis2dh12_t
 LIS2DH12 device descriptor. More...
 
struct  lis2dh12_int_params_t
 Parameter for interrupt configuration. More...
 
union  lis2dh12_fifo_data_t
 LIS2DH12 FIFO data struct. More...
 
struct  lis2dh12_fifo_t
 LIS2DH12 FIFO config values. More...
 

Macros

#define LIS2DH12_ADDR_DEFAULT   (0x19)
 Default I2C slave address for LIS2DH12 devices.
 
#define LIS2DH12_CLICK_X_SINGLE   (1 << 0)
 single click on X axis
 
#define LIS2DH12_CLICK_X_DOUBLE   (1 << 1)
 double click on X axis
 
#define LIS2DH12_CLICK_Y_SINGLE   (1 << 2)
 single click on Y axis
 
#define LIS2DH12_CLICK_Y_DOUBLE   (1 << 3)
 double click on Y axis
 
#define LIS2DH12_CLICK_Z_SINGLE   (1 << 4)
 single click on Z axis
 
#define LIS2DH12_CLICK_Z_DOUBLE   (1 << 5)
 double click on Z axis
 

Enumerations

enum  lis2dh12_scale_t { LIS2DH12_SCALE_2G = 0x0 , LIS2DH12_SCALE_4G = 0x1 , LIS2DH12_SCALE_8G = 0x2 , LIS2DH12_SCALE_16G = 0x3 }
 Available scale values. More...
 
enum  lis2dh12_rate_t {
  LIS2DH12_RATE_1HZ = 0x1 , LIS2DH12_RATE_10HZ = 0x2 , LIS2DH12_RATE_25HZ = 0x3 , LIS2DH12_RATE_50HZ = 0x4 ,
  LIS2DH12_RATE_100HZ = 0x5 , LIS2DH12_RATE_200HZ = 0x6 , LIS2DH12_RATE_400HZ = 0x7 , LIS2DH12_RATE_1620HZ = 0x8 ,
  LIS2DH12_RATE_VERYHIGH = 0x9
}
 Available sampling rates. More...
 
enum  lis2dh12_resolution_t { LIS2DH12_POWER_DOWN = 0 , LIS2DH12_POWER_LOW = 1 , LIS2DH12_POWER_NORMAL = 2 , LIS2DH12_POWER_HIGH = 3 }
 Available resolutions. More...
 
enum  lis2dh12_hp_mode_t { LIS2DH12_HP_MODE_NORMAL = 0x0 , LIS2DH12_HP_MODE_REFERENCE = 0x1 , LIS2DH12_HP_MODE_AUTORESET = 0x3 }
 LIS2DH12 high pass modes. More...
 
enum  lis2dh12_hp_freq_t { LIS2DH12_HP_FREQ_DIV50 = 0 , LIS2DH12_HP_FREQ_DIV100 = 1 , LIS2DH12_HP_FREQ_DIV200 = 2 , LIS2DH12_HP_FREQ_DIV400 = 3 }
 LIS2DH12 high pass cutoff frequency. More...
 
enum  {
  LIS2DH12_OK = 0 , LIS2DH12_NOBUS = -1 , LIS2DH12_NODEV = -2 , LIS2DH12_NOINT = -3 ,
  LIS2DH12_NODATA = -4
}
 Status and error return codes. More...
 
enum  { LIS2DH12_INT1 = 1 , LIS2DH12_INT2 = 2 }
 
enum  lis2dh12_fifo_mode_t { LIS2DH12_FIFO_MODE_BYPASS = 0 , LIS2DH12_FIFO_MODE_FIFOMODE , LIS2DH12_FIFO_MODE_STREAM , LIS2DH12_FIFO_MODE_STREAMtoFIFO }
 LIS2DH12 FIFO modes. More...
 

Functions

void lis2dh12_cfg_threshold_event (const lis2dh12_t *dev, uint32_t mg, uint32_t us, uint8_t axis, uint8_t event, uint8_t pin)
 Configure a threshold event An Interrupt will be generated if acceleration exceeds the set threshold around the current reference value. More...
 
void lis2dh12_cfg_click_event (const lis2dh12_t *dev, uint32_t mg, uint32_t us_limit, uint32_t us_latency, uint32_t us_window, uint8_t click, uint8_t pin)
 Configure a click event A click event is generated when the acceleration exceeds the set threshold for less than us_limit ┬Ás. More...
 
void lis2dh12_cfg_disable_event (const lis2dh12_t *dev, uint8_t event, uint8_t pin)
 Disable interrupt generation for an event This disables an interrupt on pin if a previously configured event occurs. More...
 
int lis2dh12_wait_event (const lis2dh12_t *dev, uint8_t pin, bool stale_events)
 Wait for an interrupt event This function will block until an interrupt is received. More...
 
int lis2dh12_set_fifo (const lis2dh12_t *dev, const lis2dh12_fifo_t *config)
 Set the FIFO configuration. More...
 
int lis2dh12_restart_fifo (const lis2dh12_t *dev)
 Restart the FIFO mode this sets the FIFO mode in BYPASS mode and then back to previous mode Note: The LIS module disables the FIFO after interrupt automatically, it is recommended to set the FIFO in BYPASS mode and then back to old FIFO mode to enable the FIFO again. More...
 
uint8_t lis2dh12_read_fifo_data (const lis2dh12_t *dev, lis2dh12_fifo_data_t *fifo_data, uint8_t number)
 This function will read a given number of data from FIFO reads amount of data that is available in FIFO. More...
 
int lis2dh12_init (lis2dh12_t *dev, const lis2dh12_params_t *params)
 Initialize the given LIS2DH12 sensor device. More...
 
int lis2dh12_read (const lis2dh12_t *dev, lis2dh12_fifo_data_t *data)
 Read acceleration data from the given device. More...
 
int lis2dh12_read_temperature (const lis2dh12_t *dev, int16_t *temp)
 Read temperature data from the given device. More...
 
int lis2dh12_clear_data (const lis2dh12_t *dev)
 Clear the LIS2DH12 memory, clears all sampled data. More...
 
int lis2dh12_set_scale (lis2dh12_t *dev, lis2dh12_scale_t scale)
 Change device measuring range. More...
 
lis2dh12_scale_t lis2dh12_get_scale (lis2dh12_t *dev)
 Get device measuring range. More...
 
int lis2dh12_set_datarate (const lis2dh12_t *dev, lis2dh12_rate_t rate)
 Change device sampling rate. More...
 
uint16_t lis2dh12_get_datarate (const lis2dh12_t *dev)
 Get device sampling rate in Hz. More...
 
int lis2dh12_set_resolution (const lis2dh12_t *dev, lis2dh12_resolution_t resolution)
 Change device resolution. More...
 
lis2dh12_resolution_t lis2dh12_get_resolution (const lis2dh12_t *dev)
 Get device resolution. More...
 
int lis2dh12_set_highpass (const lis2dh12_t *dev, const lis2dh12_highpass_t *config)
 Configures the high pass filter. More...
 
int lis2dh12_set_reference (const lis2dh12_t *dev, uint8_t reference)
 Set the reference value to control the high-pass reference. More...
 
int lis2dh12_poweron (const lis2dh12_t *dev)
 Power on the given device and resets resolution and sampling rate to default values in the device descriptor parameters. More...
 
int lis2dh12_poweroff (const lis2dh12_t *dev)
 Power off the given device. More...
 
const saul_driver_t lis2dh12_saul_driver
 Export the SAUL interface for this driver.
 
const saul_driver_t lis2dh12_saul_temp_driver