ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_interface_lis2dh12.h File Reference
#include "ruuvi_driver_enabled_modules.h"
#include "ruuvi_driver_error.h"
#include "ruuvi_driver_sensor.h"
#include <stdbool.h>
#include <stddef.h>
#include "lis2dh12_reg.h"

Go to the source code of this file.

Data Structures

struct  ri_lis2dh12_dev
 context for LIS2DH12 More...
 

Macros

#define RI_LIS2DH12_SELFTEST_DIFF_MIN   (17)
 Minimum counts of self-test change in 10 bit resolution 2 G scale, ref datasheet. More...
 
#define RI_LIS2DH12_SELFTEST_DIFF_MAX   (360)
 Maximum counts of self-test change in 10 bit resolution 2 G scale, ref datasheet. More...
 
#define RI_LIS2DH12_DEFAULT_SCALE   (2U)
 Scale used on "default" setting. More...
 
#define RI_LIS2DH12_DEFAULT_RESOLUTION   (10U)
 Resolution used on "default" setting. More...
 
#define LIS_SUCCESS   (0)
 No error in LIS driver. More...
 
#define SELF_TEST_DELAY_MS   (100U)
 At least 3 samples at 400 Hz, but recommended value 100. More...
 
#define SELF_TEST_SAMPLES_NUM   (5)
 5 samples More...
 

Functions

rd_status_t ri_lis2dh12_init (rd_sensor_t *acceleration_sensor, rd_bus_t bus, uint8_t handle)
 rd_sensor_init_fp More...
 
rd_status_t ri_lis2dh12_uninit (rd_sensor_t *acceleration_sensor, rd_bus_t bus, uint8_t handle)
 rd_sensor_init_fp More...
 
rd_status_t ri_lis2dh12_samplerate_set (uint8_t *samplerate)
 rd_sensor_setup_fp More...
 
rd_status_t ri_lis2dh12_samplerate_get (uint8_t *samplerate)
 rd_sensor_setup_fp More...
 
rd_status_t ri_lis2dh12_resolution_set (uint8_t *resolution)
 rd_sensor_setup_fp More...
 
rd_status_t ri_lis2dh12_resolution_get (uint8_t *resolution)
 rd_sensor_setup_fp More...
 
rd_status_t ri_lis2dh12_scale_set (uint8_t *scale)
 rd_sensor_setup_fp More...
 
rd_status_t ri_lis2dh12_scale_get (uint8_t *scale)
 rd_sensor_setup_fp More...
 
rd_status_t ri_lis2dh12_dsp_set (uint8_t *dsp, uint8_t *parameter)
 rd_sensor_dsp_fp More...
 
rd_status_t ri_lis2dh12_dsp_get (uint8_t *dsp, uint8_t *parameter)
 rd_sensor_dsp_fp More...
 
rd_status_t ri_lis2dh12_mode_set (uint8_t *)
 rd_sensor_setup_fp More...
 
rd_status_t ri_lis2dh12_mode_get (uint8_t *)
 rd_sensor_setup_fp More...
 
rd_status_t ri_lis2dh12_data_get (rd_sensor_data_t *const data)
 rd_sensor_data_fp More...
 
rd_status_t ri_lis2dh12_fifo_use (const bool enable)
 Enable 32-level FIFO in LIS2DH12 If FIFO is enabled, values are stored on LIS2DH12 FIFO and oldest element is returned on data read. More...
 
rd_status_t ri_lis2dh12_fifo_read (size_t *num_elements, rd_sensor_data_t *data)
 Read FIFO Reads up to num_elements data points from FIFO and populates pointer data with them. More...
 
rd_status_t ri_lis2dh12_fifo_interrupt_use (const bool enable)
 Enable FIFO full interrupt on LIS2DH12. Triggers as ACTIVE HIGH interrupt once FIFO has 32 elements. More...
 
rd_status_t ri_lis2dh12_activity_interrupt_use (const bool enable, float *limit_g)
 Enable activity interrupt on LIS2DH12. More...
 

Detailed Description

Author
Otso Jousimaa otso@.nosp@m.ojou.nosp@m.sima..nosp@m.net
Date
2020-04-24

Interface for LIS2DH12 basic usage. The underlying platform must provide functions for SPI and/or I2C access, ruuvi_interface_spi_lis2dh12.h.

Testing the interface with ruuvi_driver_sensor_test.h

uint8_t handle = 0;
bus = RD_BUS_SPI;
handle = RUUVI_BOARD_SPI_SS_ACCELEROMETER_PIN;
err_code = test_sensor_init(init, bus, handle);
err_code = test_sensor_setup(init, bus, handle);
err_code = test_sensor_modes(init, bus, handle);
uint32_t rd_status_t
bitfield for representing errors
#define RD_ERROR_CHECK(error, mask)
Shorthand macro for calling the rd_error_check with current file & line.
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_SELFTEST
Self-test fail.
rd_status_t ri_lis2dh12_init(rd_sensor_t *p_sensor, rd_bus_t bus, uint8_t handle)
rd_sensor_init_fp
rd_status_t(* rd_sensor_init_fp)(rd_sensor_t *const p_sensor, const rd_bus_t bus, const uint8_t handle)
Initialize and uninitialize sensor. Init and uninit will setup sensor with function pointers....
rd_bus_t
Type of bus sensor uses.
@ RD_BUS_SPI
SPI bus.
@ RD_BUS_NONE
No bus, internal to IC.

Definition in file ruuvi_interface_lis2dh12.h.