lis2dh12.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
36 #ifndef LIS2DH12_H
37 #define LIS2DH12_H
38 
39 #include <stdint.h>
40 
41 #include "saul.h"
42 
43 #ifdef MODULE_LIS2DH12_SPI
44 #include "periph/spi.h"
45 #include "periph/gpio.h"
46 #else
47 #include "periph/i2c.h"
48 #endif
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 #if defined(MODULE_LIS2DH12) || defined(DOXYGEN)
55 
58 #define LIS2DH12_ADDR_DEFAULT (0x19)
59 #endif
60 
64 typedef enum {
70 
77 typedef enum {
86 
90 typedef struct {
91 #ifdef MODULE_LIS2DH12_SPI
92  spi_t spi;
93  gpio_t cs;
94 #else
96  uint8_t addr;
97 #endif
101 
105 typedef struct {
107  uint16_t comp;
108 } lis2dh12_t;
109 
113 enum {
117 };
118 
123 
134 int lis2dh12_init(lis2dh12_t *dev, const lis2dh12_params_t *params);
135 
145 int lis2dh12_read(const lis2dh12_t *dev, int16_t *data);
146 
155 int lis2dh12_poweron(const lis2dh12_t *dev);
156 
165 int lis2dh12_poweroff(const lis2dh12_t *dev);
166 
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif /* LIS2DH12_H */
172 
sample with 400Hz
Definition: lis2dh12.h:84
const saul_driver_t lis2dh12_saul_driver
Export the SAUL interface for this driver.
int lis2dh12_read(const lis2dh12_t *dev, int16_t *data)
Read acceleration data from the given device.
int lis2dh12_init(lis2dh12_t *dev, const lis2dh12_params_t *params)
Initialize the given LIS2DH12 sensor device.
Low-level GPIO peripheral driver interface definitions.
uint16_t comp
scale compensation factor
Definition: lis2dh12.h:107
lis2dh12_rate_t rate
sampling rate used
Definition: lis2dh12.h:99
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:157
Definition of the RIOT actuator/sensor interface.
Definition: saul.h:239
sample with 200Hz
Definition: lis2dh12.h:83
Low-level SPI peripheral driver interface definition.
uint8_t addr
device address on the I2C bus
Definition: lis2dh12.h:96
lis2dh12_scale_t scale
sampling sensitivity used
Definition: lis2dh12.h:98
sample with 50Hz
Definition: lis2dh12.h:81
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
const lis2dh12_params_t * p
device configuration
Definition: lis2dh12.h:106
i2c_t i2c
I2C bus the device is connected to.
Definition: lis2dh12.h:95
sample with 100Hz
Definition: lis2dh12.h:82
sample with 1Hz
Definition: lis2dh12.h:78
sample with 25Hz
Definition: lis2dh12.h:80
int lis2dh12_poweroff(const lis2dh12_t *dev)
Power off the given device.
bus interface error
Definition: lis2dh12.h:115
lis2dh12_rate_t
Available sampling rates.
Definition: lis2dh12.h:77
LIS2DH12 device descriptor.
Definition: lis2dh12.h:105
int lis2dh12_poweron(const lis2dh12_t *dev)
Power on the given device.
sample with 10Hz
Definition: lis2dh12.h:79
everything was fine
Definition: lis2dh12.h:114
lis2dh12_scale_t
Available scale values.
Definition: lis2dh12.h:64
LIS2DH12 configuration parameters.
Definition: lis2dh12.h:90
unable to talk to device
Definition: lis2dh12.h:116
unsigned int spi_t
Default type for SPI devices.
Definition: spi.h:118
Low-level I2C peripheral driver interface definition.