2 #if (RI_LIS2DH12_ENABLED || DOXYGEN)
9 #include "lis2dh12_reg.h"
15 #ifdef RUUVI_NRF5_SDK15_LIS2GH12_DEBUG
16 #ifndef RUUVI_NRF5_SDK15_LIS2GH12_LOG_LEVEL
17 #define RUUVI_NRF5_SDK15_LIS2GH12_LOG_LEVEL RI_LOG_LEVEL_DEBUG
20 #define LOGD(fmt, ...) \
22 char buff[1024] = {0}; \
23 snprintf(buff, sizeof(buff), ":%d:%s(): " fmt, \
24 __LINE__, __func__, ##__VA_ARGS__); \
25 ri_log(RUUVI_NRF5_SDK15_LIS2GH12_LOG_LEVEL, buff); \
28 #define LOGD(fmt, ...)
51 #define NM_BIT_DIVEDER (64U)
52 #define MOTION_THRESHOLD_MAX (0x7FU)
53 #define PWRON_DELAY_MS (10U)
56 #define VERIFY_SENSOR_SLEEPS() do { \
57 uint8_t MACRO_MODE = 0; \
58 ri_lis2dh12_mode_get(&MACRO_MODE); \
59 if(RD_SENSOR_CFG_SLEEP != MACRO_MODE) { return RD_ERROR_INVALID_STATE; } \
84 static const char m_acc_name[] =
"LIS2DH12";
86 static void lis2dh12_get_samples_selftest (axis3bit16_t * p_data_raw_acceleration)
88 axis3bit16_t data_raw_acceleration = {0};
95 lis2dh12_acceleration_raw_get (&dev.
ctx, data_raw_acceleration.u8bit);
100 lis2dh12_acceleration_raw_get (&dev.
ctx, data_raw_acceleration.u8bit);
101 axis_x += data_raw_acceleration.i16bit[0];
102 axis_y += data_raw_acceleration.i16bit[1];
103 axis_z += data_raw_acceleration.i16bit[2];
112 static rd_status_t lis2dh12_verify_selftest (
const axis3bit16_t *
const new,
113 const axis3bit16_t *
const old)
124 for (
size_t ii = 0; ii <
NUM_AXIS; ii++)
126 int16_t diff =
new->i16bit[ii] - old->i16bit[ii];
130 if (0 > diff) { diff = 0 - diff; }
134 LOGD (
"diff < min = %d\r\n", diff);
140 LOGD (
"diff > max = %d\r\n", diff);
150 const uint8_t handle)
180 lis2dh12_device_id_get (&dev.
ctx, &whoamI);
182 if (whoamI != LIS2DH12_ID)
200 lis_ret_code |= lis2dh12_temperature_meas_set (&dev.
ctx, LIS2DH12_TEMP_ENABLE);
202 lis_ret_code |= lis2dh12_block_data_update_set (&dev.
ctx, PROPERTY_ENABLE);
204 lis_ret_code |= lis2dh12_high_pass_on_outputs_set (&dev.
ctx, PROPERTY_DISABLE);
217 axis3bit16_t data_raw_acceleration_old = {0};
218 axis3bit16_t data_raw_acceleration_new = {0};
225 dev.
scale = LIS2DH12_2g;
226 lis2dh12_full_scale_set (&dev.
ctx, dev.
scale);
233 lis_ret_code = lis2dh12_self_test_set (&dev.
ctx, dev.
selftest);
235 lis2dh12_get_samples_selftest (&data_raw_acceleration_old);
236 dev.
selftest = LIS2DH12_ST_POSITIVE;
238 lis2dh12_get_samples_selftest (&data_raw_acceleration_new);
239 lis_ret_code = lis2dh12_verify_selftest (&data_raw_acceleration_new,
240 &data_raw_acceleration_old);
242 LOGD (
"selftest = LIS2DH12_ST_POSITIVE.Error = %08x\r\n", err_code);
243 dev.
selftest = LIS2DH12_ST_NEGATIVE;
245 lis2dh12_get_samples_selftest (&data_raw_acceleration_new);
246 lis_ret_code = lis2dh12_verify_selftest (&data_raw_acceleration_new,
247 &data_raw_acceleration_old);
249 LOGD (
"selftest = LIS2DH12_ST_NEGATIVE.Error = %08x\r\n", err_code);
252 lis_ret_code = lis2dh12_self_test_set (&dev.
ctx, dev.
selftest);
256 lis_ret_code = lis2dh12_data_rate_set (&dev.
ctx, dev.
samplerate);
258 LOGD (
"end. Error = %08x\r\n", err_code);
267 if (NULL == p_sensor)
270 LOGD (
"p_sensor. Error = %08x\r\n", err_code);
275 LOGD (
"write_reg. Error = %08x\r\n", err_code);
279 err_code |= dev_ctx_init (bus, handle);
280 LOGD (
"dev_ctx_init. Error = %08x\r\n", err_code);
282 p_sensor->
name = m_acc_name;
291 err_code |= check_whoami();
292 LOGD (
"check_whoami. Error = %08x\r\n", err_code);
297 err_code |= clear_sensor_state();
298 LOGD (
"clear_sensor_state. Error = %08x\r\n", err_code);
303 err_code |= selftest();
304 LOGD (
"selftest. Error = %08x\r\n", err_code);
337 memset (&dev, 0,
sizeof (dev));
341 LOGD (
"end. Error = %08x\r\n", err_code);
354 if (NULL == p_sensor)
363 int32_t lis_ret_code = lis2dh12_data_rate_set (& (dev.
ctx), dev.
samplerate);
364 memset (&dev, 0,
sizeof (dev));
387 int32_t lis_ret_code;
393 else if (1 == *samplerate) { dev.
samplerate = LIS2DH12_ODR_1Hz; }
394 else if (10 >= *samplerate) { dev.
samplerate = LIS2DH12_ODR_10Hz; }
395 else if (25 >= *samplerate) { dev.
samplerate = LIS2DH12_ODR_25Hz; }
396 else if (50 >= *samplerate) { dev.
samplerate = LIS2DH12_ODR_50Hz; }
397 else if (100 >= *samplerate) { dev.
samplerate = LIS2DH12_ODR_100Hz; }
398 else if (200 >= *samplerate) { dev.
samplerate = LIS2DH12_ODR_200Hz; }
407 lis_ret_code = lis2dh12_data_rate_set (& (dev.
ctx), dev.
samplerate);
423 int32_t lis_ret_code;
424 lis_ret_code = lis2dh12_data_rate_get (& (dev.
ctx), &dev.
samplerate);
429 case LIS2DH12_ODR_1Hz:
433 case LIS2DH12_ODR_10Hz:
437 case LIS2DH12_ODR_25Hz:
441 case LIS2DH12_ODR_50Hz:
445 case LIS2DH12_ODR_100Hz:
449 case LIS2DH12_ODR_200Hz:
453 case LIS2DH12_ODR_400Hz:
457 case LIS2DH12_ODR_5kHz376_LP_1kHz344_NM_HP:
461 case LIS2DH12_ODR_1kHz620_LP:
482 int32_t lis_ret_code;
488 else if (8 >= *resolution) { dev.
resolution = LIS2DH12_LP_8bit; }
489 else if (10 >= *resolution) { dev.
resolution = LIS2DH12_NM_10bit; }
490 else if (12 >= *resolution) { dev.
resolution = LIS2DH12_HR_12bit; }
495 lis_ret_code = lis2dh12_operating_mode_set (& (dev.
ctx), dev.
resolution);
508 int32_t lis_ret_code;
509 lis_ret_code = lis2dh12_operating_mode_get (& (dev.
ctx), &dev.
resolution);
514 case LIS2DH12_LP_8bit:
518 case LIS2DH12_NM_10bit:
522 case LIS2DH12_HR_12bit:
544 int32_t lis_ret_code;
550 else if (2 >= *scale) { dev.
scale = LIS2DH12_2g; }
551 else if (4 >= *scale) { dev.
scale = LIS2DH12_4g; }
552 else if (8 >= *scale) { dev.
scale = LIS2DH12_8g; }
553 else if (16 >= *scale) { dev.
scale = LIS2DH12_16g; }
562 lis_ret_code = lis2dh12_full_scale_set (& (dev.
ctx), dev.
scale);
575 int32_t lis_ret_code;
576 lis_ret_code = lis2dh12_full_scale_get (& (dev.
ctx), &dev.
scale);
615 if (NULL == dsp || NULL == parameter) {
return RD_ERROR_NULL; }
619 int32_t lis_ret_code;
621 uint8_t orig_dsp, orig_param;
630 lis2dh12_hpcf_t hpcf;
639 hpcf = LIS2DH12_LIGHT;
644 hpcf = LIS2DH12_MEDIUM;
648 hpcf = LIS2DH12_STRONG;
653 hpcf = LIS2DH12_AGGRESSIVE;
662 lis_ret_code = lis2dh12_high_pass_bandwidth_set (& (dev.
ctx), hpcf);
664 lis_ret_code = lis2dh12_high_pass_mode_set (& (dev.
ctx), LIS2DH12_NORMAL);
666 lis_ret_code = lis2dh12_high_pass_on_outputs_set (& (dev.
ctx), PROPERTY_ENABLE);
679 lis_ret_code = lis2dh12_high_pass_on_outputs_set (& (dev.
ctx), PROPERTY_DISABLE);
691 int32_t lis_ret_code;
693 lis2dh12_hpcf_t hpcf;
694 lis_ret_code = lis2dh12_high_pass_bandwidth_get (& (dev.
ctx), &hpcf);
696 lis_ret_code = lis2dh12_high_pass_on_outputs_get (& (dev.
ctx), &mode);
708 case LIS2DH12_MEDIUM:
712 case LIS2DH12_STRONG:
716 case LIS2DH12_AGGRESSIVE:
732 int32_t lis_ret_code;
738 uint8_t current_mode;
751 lis_ret_code = lis2dh12_data_rate_set (& (dev.
ctx), dev.
samplerate);
756 lis_ret_code = lis2dh12_data_rate_set (& (dev.
ctx), dev.
samplerate);
767 lis_ret_code = lis2dh12_data_rate_set (& (dev.
ctx), LIS2DH12_POWER_DOWN);
773 lis_ret_code = lis2dh12_data_rate_set (& (dev.
ctx), dev.
samplerate);
810 static rd_status_t rawToC (
const uint8_t *
const raw_temperature,
814 int16_t value = (raw_temperature[1] * 256) + raw_temperature[0];
818 case LIS2DH12_LP_8bit:
819 *temperature = lis2dh12_from_lsb_lp_to_celsius (value);
822 case LIS2DH12_NM_10bit:
823 *temperature = lis2dh12_from_lsb_nm_to_celsius (value);
826 case LIS2DH12_HR_12bit:
827 *temperature = lis2dh12_from_lsb_hr_to_celsius (value);
846 static rd_status_t rawToMg (
const axis3bit16_t * raw_acceleration,
847 float * acceleration)
851 for (
size_t ii = 0; ii < 3; ii++)
858 case LIS2DH12_LP_8bit:
859 acceleration[ii] = lis2dh12_from_fs2_lp_to_mg (raw_acceleration->i16bit[ii]);
862 case LIS2DH12_NM_10bit:
863 acceleration[ii] = lis2dh12_from_fs2_nm_to_mg (raw_acceleration->i16bit[ii]);
866 case LIS2DH12_HR_12bit:
867 acceleration[ii] = lis2dh12_from_fs2_hr_to_mg (raw_acceleration->i16bit[ii]);
881 case LIS2DH12_LP_8bit:
882 acceleration[ii] = lis2dh12_from_fs4_lp_to_mg (raw_acceleration->i16bit[ii]);
885 case LIS2DH12_NM_10bit:
886 acceleration[ii] = lis2dh12_from_fs4_nm_to_mg (raw_acceleration->i16bit[ii]);
889 case LIS2DH12_HR_12bit:
890 acceleration[ii] = lis2dh12_from_fs4_hr_to_mg (raw_acceleration->i16bit[ii]);
904 case LIS2DH12_LP_8bit:
905 acceleration[ii] = lis2dh12_from_fs8_lp_to_mg (raw_acceleration->i16bit[ii]);
908 case LIS2DH12_NM_10bit:
909 acceleration[ii] = lis2dh12_from_fs8_nm_to_mg (raw_acceleration->i16bit[ii]);
912 case LIS2DH12_HR_12bit:
913 acceleration[ii] = lis2dh12_from_fs8_hr_to_mg (raw_acceleration->i16bit[ii]);
927 case LIS2DH12_LP_8bit:
928 acceleration[ii] = lis2dh12_from_fs16_lp_to_mg (raw_acceleration->i16bit[ii]);
931 case LIS2DH12_NM_10bit:
932 acceleration[ii] = lis2dh12_from_fs16_nm_to_mg (raw_acceleration->i16bit[ii]);
935 case LIS2DH12_HR_12bit:
936 acceleration[ii] = lis2dh12_from_fs16_hr_to_mg (raw_acceleration->i16bit[ii]);
963 int32_t lis_ret_code;
964 axis3bit16_t raw_acceleration;
965 uint8_t raw_temperature[2];
966 memset (raw_acceleration.u8bit, 0x00, 3 * sizeof (int16_t));
967 lis_ret_code = lis2dh12_acceleration_raw_get (& (dev.
ctx), raw_acceleration.u8bit);
969 lis_ret_code = lis2dh12_temperature_raw_get (& (dev.
ctx), raw_temperature);
972 float acceleration[3];
974 err_code |= rawToMg (&raw_acceleration, acceleration);
975 err_code |= rawToC (raw_temperature, &temperature);
993 d_acceleration.
data = values;
999 values[0] = acceleration[0] / 1000.0;
1000 values[1] = acceleration[1] / 1000.0;
1001 values[2] = acceleration[2] / 1000.0;
1002 values[3] = temperature;
1003 d_acceleration.
valid = acc_fields;
1004 d_acceleration.
fields = acc_fields;
1017 int32_t lis_ret_code;
1020 if (enable) { mode = LIS2DH12_DYNAMIC_STREAM_MODE; }
1021 else { mode = LIS2DH12_BYPASS_MODE; }
1023 lis_ret_code = lis2dh12_fifo_set (& (dev.
ctx), enable);
1025 lis_ret_code = lis2dh12_fifo_mode_set (& (dev.
ctx), mode);
1034 if (NULL == num_elements || NULL == p_data) {
return RD_ERROR_NULL; }
1036 uint8_t elements = 0;
1038 int32_t lis_ret_code;
1039 lis_ret_code = lis2dh12_fifo_data_level_get (& (dev.
ctx), &elements);
1052 if (elements > *num_elements) { elements = *num_elements; }
1057 axis3bit16_t raw_acceleration;
1058 float acceleration[3];
1060 for (
size_t ii = 0; ii < elements; ii++)
1062 lis_ret_code = lis2dh12_acceleration_raw_get (& (dev.
ctx), raw_acceleration.u8bit);
1065 err_code |= rawToMg (&raw_acceleration, acceleration);
1072 acceleration[0] = acceleration[0] / 1000.0;
1073 acceleration[1] = acceleration[1] / 1000.0;
1074 acceleration[2] = acceleration[2] / 1000.0;
1075 d_acceleration.
data = acceleration;
1076 d_acceleration.
valid = acc_fields;
1077 d_acceleration.
fields = acc_fields;
1083 *num_elements = elements;
1091 int32_t lis_ret_code;
1092 lis2dh12_ctrl_reg3_t ctrl = { 0 };
1098 lis_ret_code = lis2dh12_fifo_watermark_set (& (dev.
ctx), 31);
1100 ctrl.i1_wtm = PROPERTY_ENABLE;
1103 lis_ret_code = lis2dh12_pin_int1_config_set (& (dev.
ctx), &ctrl);
1126 int32_t lis_ret_code;
1127 lis2dh12_hp_t high_pass = LIS2DH12_ON_INT1_GEN;
1128 lis2dh12_ctrl_reg6_t ctrl6 = { 0 };
1129 lis2dh12_int1_cfg_t cfg = { 0 };
1131 if (NULL == limit_g)
1135 else if ( (0 > *limit_g) && enable)
1141 cfg.xhie = PROPERTY_ENABLE;
1142 cfg.yhie = PROPERTY_ENABLE;
1143 cfg.zhie = PROPERTY_ENABLE;
1144 ctrl6.i2_ia1 = PROPERTY_ENABLE;
1186 threshold = (uint32_t) (*limit_g / divisor) + 1;
1194 *limit_g = ( (float) threshold) * divisor;
1196 lis_ret_code = lis2dh12_int1_gen_threshold_set (& (dev.
ctx), threshold);
1202 high_pass = LIS2DH12_DISC_FROM_INT_GENERATOR;
1208 lis_ret_code = lis2dh12_high_pass_int_conf_set (& (dev.
ctx), high_pass);
1211 lis_ret_code = lis2dh12_int1_gen_conf_set (& (dev.
ctx), &cfg);
1214 lis_ret_code = lis2dh12_pin_int2_config_set (& (dev.
ctx), &ctrl6);
#define RD_ERROR_INVALID_PARAM
Invalid Parameter.
#define RD_ERROR_NULL
Null Pointer.
#define RD_ERROR_FATAL
Program should always reset after this.
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_ERROR_NOT_IMPLEMENTED
Not implemented yet.
#define RD_FLOAT_INVALID
Signal that value should not be used.
#define RD_ERROR_NOT_SUPPORTED
Not supported.
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_SELFTEST
Self-test fail.
#define RD_ERROR_NOT_FOUND
Not found.
#define RD_UINT64_INVALID
Signal that value should not be used.
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
#define RD_ERROR_INTERNAL
Internal Error.
#define RI_LIS2DH12_SELFTEST_DIFF_MIN
Minimum counts of self-test change in 10 bit resolution 2 G scale, ref datasheet.
rd_status_t ri_lis2dh12_resolution_set(uint8_t *resolution)
rd_sensor_setup_fp
#define SELF_TEST_SAMPLES_NUM
5 samples
rd_status_t ri_lis2dh12_mode_get(uint8_t *mode)
rd_sensor_setup_fp
#define LIS_SUCCESS
No error in LIS driver.
#define SELF_TEST_DELAY_MS
At least 3 samples at 400 Hz, but recommended value 100.
rd_status_t ri_lis2dh12_samplerate_get(uint8_t *samplerate)
rd_sensor_setup_fp
rd_status_t ri_lis2dh12_dsp_get(uint8_t *dsp, uint8_t *parameter)
rd_sensor_dsp_fp
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 el...
rd_status_t ri_lis2dh12_scale_set(uint8_t *scale)
rd_sensor_setup_fp
rd_status_t ri_lis2dh12_mode_set(uint8_t *mode)
rd_sensor_setup_fp
rd_status_t ri_lis2dh12_dsp_set(uint8_t *dsp, uint8_t *parameter)
rd_sensor_dsp_fp
rd_status_t ri_lis2dh12_samplerate_set(uint8_t *samplerate)
rd_sensor_setup_fp
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.
rd_status_t ri_lis2dh12_uninit(rd_sensor_t *p_sensor, rd_bus_t bus, uint8_t handle)
rd_sensor_init_fp
rd_status_t ri_lis2dh12_data_get(rd_sensor_data_t *const data)
rd_sensor_data_fp
#define RI_LIS2DH12_SELFTEST_DIFF_MAX
Maximum counts of self-test change in 10 bit resolution 2 G scale, ref datasheet.
rd_status_t ri_lis2dh12_fifo_read(size_t *num_elements, rd_sensor_data_t *p_data)
Read FIFO Reads up to num_elements data points from FIFO and populates pointer data with them.
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 ri_lis2dh12_resolution_get(uint8_t *resolution)
rd_sensor_setup_fp
rd_status_t ri_lis2dh12_activity_interrupt_use(const bool enable, float *const limit_g)
Enable activity interrupt on LIS2DH12.
rd_status_t ri_lis2dh12_scale_get(uint8_t *scale)
rd_sensor_setup_fp
#define RD_SENSOR_DSP_LAST
Return last value from sensor. Parameter: No effect. Use default.
#define RD_SENSOR_ERR_NOT_SUPPORTED
Error code, given parameter is not supported by sensor.
bool rd_sensor_is_init(const rd_sensor_t *const sensor)
Check if given sensor structure is already initialized.
#define RD_SENSOR_CFG_SLEEP
Sensor should go to sleep immediately.
#define RD_SENSOR_CFG_MAX
Configure largest supported and implemented value.
#define RD_SENSOR_CFG_DEFAULT
Default value, always valid for the sensor.
void rd_sensor_uninitialize(rd_sensor_t *const p_sensor)
Mark sensor as uninitialized by calling the generic initialization. Will not clear the name of the se...
rd_status_t rd_sensor_configuration_get(const rd_sensor_t *sensor, rd_sensor_configuration_t *config)
Implementation of ref rd_configuration_fp.
void rd_sensor_initialize(rd_sensor_t *const p_sensor)
Initialize sensor struct with non-null pointers which return RD_ERROR_NOT_INITIALIZED.
#define RD_SENSOR_ERR_INVALID
Error code, given parameter is invalid.
#define RD_SENSOR_CFG_CUSTOM_3
Configuration range is 0...200, i.e. 0 ... 0xC8. Use C9 ... CF as sensor-specific values.
#define RD_SENSOR_CFG_CUSTOM_1
Configuration range is 0...200, i.e. 0 ... 0xC8. Use C9 ... CF as sensor-specific values.
void rd_sensor_data_populate(rd_sensor_data_t *const target, const rd_sensor_data_t *const provided, const rd_sensor_data_fields_t requested)
Populate given target data with data provided by sensor as requested.
rd_status_t rd_sensor_configuration_set(const rd_sensor_t *sensor, rd_sensor_configuration_t *config)
Implementation of ref rd_configuration_fp.
#define RD_SENSOR_CFG_MIN
Configure smallest supported and implemented value.
#define RD_SENSOR_CFG_CONTINUOUS
Sensor will keep sampling at defined sample rate.
#define RD_SENSOR_DSP_HIGH_PASS
High pass sensor values Parameter: coefficient.
#define RD_SENSOR_CFG_NO_CHANGE
Do not change configured value.
rd_bus_t
Type of bus sensor uses.
#define RD_SENSOR_CFG_CUSTOM_2
Configuration range is 0...200, i.e. 0 ... 0xC8. Use C9 ... CF as sensor-specific values.
uint64_t rd_sensor_timestamp_get(void)
Calls the timestamp function and returns its value.
#define RD_SENSOR_CFG_SINGLE
Sensor should go to sleep after single measurement.
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
Ruuvi sensor interface Lifecycle: Beta
#define PWRON_DELAY_MS
Milliseconds from poweron to sensor rdy. 5ms typ.
#define NM_BIT_DIVEDER
Normal mode uses 10 bits in 16 bit field, leading to 2^6 factor in results.
#define VERIFY_SENSOR_SLEEPS()
Macro for checking that sensor is in sleep mode before configuration.
#define MOTION_THRESHOLD_MAX
Highest threshold value allowed.
int32_t ri_spi_lis2dh12_write(void *dev_ptr, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
int32_t ri_spi_lis2dh12_read(void *dev_ptr, uint8_t reg_addr, uint8_t *reg_data, uint16_t len)
rd_status_t ri_delay_ms(uint32_t time)
Delay a given number of milliseconds.
unsigned int acceleration_x_g
Acceleration along X-axis, gravities.
unsigned int temperature_c
Temperature, celcius.
unsigned int acceleration_z_g
Acceleration along Z-axis, gravities.
unsigned int acceleration_y_g
Acceleration along Y-axis, gravities.
Generic sensor data struct.
float * data
Data of sensor. Must contain as many elements as fields has bits set.
uint64_t timestamp_ms
Timestamp of the event, rd_sensor_timestamp_get.
rd_sensor_data_fields_t valid
Listing of valid data in this sample.
rd_sensor_data_fields_t fields
Description of datafields which may be contained in this sample.
Interface to sensor. Some sensors can implement additional functions. The additional functions are de...
rd_sensor_data_fp data_get
rd_sensor_data_fp
rd_configuration_fp configuration_set
rd_configuration_fp
rd_sensor_setup_fp samplerate_get
rd_sensor_setup_fp
rd_sensor_setup_fp resolution_get
rd_sensor_setup_fp
rd_sensor_init_fp uninit
rd_sensor_init_fp
rd_configuration_fp configuration_get
rd_configuration_fp
rd_sensor_dsp_fp dsp_get
rd_sensor_dsp_fp
rd_sensor_data_fields_t provides
Description of data fields the sensor is able to provide.
rd_sensor_dsp_fp dsp_set
rd_sensor_dsp_fp
rd_sensor_setup_fp mode_set
rd_sensor_setup_fp
const char * name
Sensor human-readable name. Should be at most 8 bytes long.
rd_sensor_fifo_read_fp fifo_read
rd_sensor_level_interrupt_use_fp
rd_sensor_fifo_enable_fp fifo_interrupt_enable
rd_sensor_level_interrupt_use_fp
rd_sensor_level_interrupt_use_fp level_interrupt_set
rd_sensor_level_interrupt_use_fp
rd_sensor_setup_fp mode_get
rd_sensor_setup_fp
rd_sensor_setup_fp samplerate_set
rd_sensor_setup_fp
rd_sensor_fifo_enable_fp fifo_enable
rd_sensor_fifo_enable_fp
rd_sensor_init_fp init
rd_sensor_init_fp
rd_sensor_setup_fp scale_set
rd_sensor_setup_fp
rd_sensor_setup_fp resolution_set
rd_sensor_setup_fp
rd_sensor_setup_fp scale_get
rd_sensor_setup_fp
uint64_t tsample
Time of sample, rd_sensor_timestamp_get.
uint8_t handle
Device handle, SPI GPIO pin or I2C address.
lis2dh12_op_md_t resolution
Resolution, bits. 8, 10, or 12.
uint8_t mode
Operating mode. Sleep, single or continuous.
lis2dh12_st_t selftest
Self-test enabled, positive, negative or disabled.
stmdev_ctx_t ctx
Driver control structure.
lis2dh12_odr_t samplerate
Sample rate, 1 ... 200, or custom values for higher.
lis2dh12_fs_t scale
Scale, gravities. 2, 4, 8 or 16.
Union to access sensor data.
uint32_t bitfield
Bitfield used to access sensor data.
rd_sensor_data_bitfield_t datas
Structured data field.