2020-02-12 15:31:46 +01:00
|
|
|
/* ST Microelectronics IIS2DLPC 3-axis accelerometer driver
|
|
|
|
*
|
|
|
|
* Copyright (c) 2020 STMicroelectronics
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Datasheet:
|
|
|
|
* https://www.st.com/resource/en/datasheet/iis2dlpc.pdf
|
|
|
|
*/
|
|
|
|
|
2020-03-26 16:47:47 -05:00
|
|
|
#define DT_DRV_COMPAT st_iis2dlpc
|
|
|
|
|
2020-02-12 15:31:46 +01:00
|
|
|
#include <init.h>
|
|
|
|
#include <sys/__assert.h>
|
|
|
|
#include <sys/byteorder.h>
|
|
|
|
#include <logging/log.h>
|
|
|
|
#include <drivers/sensor.h>
|
|
|
|
|
2020-05-06 11:23:07 -07:00
|
|
|
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
2020-02-12 15:31:46 +01:00
|
|
|
#include <drivers/spi.h>
|
2020-05-06 11:23:07 -07:00
|
|
|
#elif DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
|
2020-02-12 15:31:46 +01:00
|
|
|
#include <drivers/i2c.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "iis2dlpc.h"
|
|
|
|
|
|
|
|
LOG_MODULE_REGISTER(IIS2DLPC, CONFIG_SENSOR_LOG_LEVEL);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* iis2dlpc_set_range - set full scale range for acc
|
|
|
|
* @dev: Pointer to instance of struct device (I2C or SPI)
|
|
|
|
* @range: Full scale range (2, 4, 8 and 16 G)
|
|
|
|
*/
|
2020-11-26 18:40:25 +01:00
|
|
|
static int iis2dlpc_set_range(const struct device *dev, uint8_t fs)
|
2020-02-12 15:31:46 +01:00
|
|
|
{
|
|
|
|
int err;
|
2020-05-28 21:23:02 +02:00
|
|
|
struct iis2dlpc_data *iis2dlpc = dev->data;
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct iis2dlpc_device_config *cfg = dev->config;
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t shift_gain = 0U;
|
2020-02-12 15:31:46 +01:00
|
|
|
|
|
|
|
err = iis2dlpc_full_scale_set(iis2dlpc->ctx, fs);
|
|
|
|
|
|
|
|
if (cfg->pm == IIS2DLPC_CONT_LOW_PWR_12bit) {
|
|
|
|
shift_gain = IIS2DLPC_SHFT_GAIN_NOLP1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!err) {
|
|
|
|
/* save internally gain for optimization */
|
|
|
|
iis2dlpc->gain =
|
2020-11-26 18:40:25 +01:00
|
|
|
IIS2DLPC_FS_TO_GAIN(fs, shift_gain);
|
2020-02-12 15:31:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* iis2dlpc_set_odr - set new sampling frequency
|
|
|
|
* @dev: Pointer to instance of struct device (I2C or SPI)
|
|
|
|
* @odr: Output data rate
|
|
|
|
*/
|
2020-04-30 20:33:38 +02:00
|
|
|
static int iis2dlpc_set_odr(const struct device *dev, uint16_t odr)
|
2020-02-12 15:31:46 +01:00
|
|
|
{
|
2020-05-28 21:23:02 +02:00
|
|
|
struct iis2dlpc_data *iis2dlpc = dev->data;
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t val;
|
2020-02-12 15:31:46 +01:00
|
|
|
|
|
|
|
/* check if power off */
|
|
|
|
if (odr == 0U) {
|
|
|
|
return iis2dlpc_data_rate_set(iis2dlpc->ctx,
|
|
|
|
IIS2DLPC_XL_ODR_OFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
val = IIS2DLPC_ODR_TO_REG(odr);
|
|
|
|
if (val > IIS2DLPC_XL_ODR_1k6Hz) {
|
|
|
|
LOG_ERR("ODR too high");
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iis2dlpc_data_rate_set(iis2dlpc->ctx, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void iis2dlpc_convert(struct sensor_value *val, int raw_val,
|
|
|
|
float gain)
|
|
|
|
{
|
2020-05-27 11:26:57 -05:00
|
|
|
int64_t dval;
|
2020-02-12 15:31:46 +01:00
|
|
|
|
|
|
|
/* Gain is in ug/LSB */
|
|
|
|
/* Convert to m/s^2 */
|
2020-05-27 11:26:57 -05:00
|
|
|
dval = ((int64_t)raw_val * gain * SENSOR_G) / 1000000LL;
|
2020-02-12 15:31:46 +01:00
|
|
|
val->val1 = dval / 1000000LL;
|
|
|
|
val->val2 = dval % 1000000LL;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static inline void iis2dlpc_channel_get_acc(const struct device *dev,
|
2020-02-12 15:31:46 +01:00
|
|
|
enum sensor_channel chan,
|
|
|
|
struct sensor_value *val)
|
|
|
|
{
|
|
|
|
int i;
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t ofs_start, ofs_stop;
|
2020-05-28 21:23:02 +02:00
|
|
|
struct iis2dlpc_data *iis2dlpc = dev->data;
|
2020-02-12 15:31:46 +01:00
|
|
|
struct sensor_value *pval = val;
|
|
|
|
|
|
|
|
switch (chan) {
|
|
|
|
case SENSOR_CHAN_ACCEL_X:
|
|
|
|
ofs_start = ofs_stop = 0U;
|
|
|
|
break;
|
|
|
|
case SENSOR_CHAN_ACCEL_Y:
|
|
|
|
ofs_start = ofs_stop = 1U;
|
|
|
|
break;
|
|
|
|
case SENSOR_CHAN_ACCEL_Z:
|
|
|
|
ofs_start = ofs_stop = 2U;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ofs_start = 0U; ofs_stop = 2U;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = ofs_start; i <= ofs_stop ; i++) {
|
|
|
|
iis2dlpc_convert(pval++, iis2dlpc->acc[i], iis2dlpc->gain);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int iis2dlpc_channel_get(const struct device *dev,
|
2020-02-12 15:31:46 +01:00
|
|
|
enum sensor_channel chan,
|
|
|
|
struct sensor_value *val)
|
|
|
|
{
|
|
|
|
switch (chan) {
|
|
|
|
case SENSOR_CHAN_ACCEL_X:
|
|
|
|
case SENSOR_CHAN_ACCEL_Y:
|
|
|
|
case SENSOR_CHAN_ACCEL_Z:
|
|
|
|
case SENSOR_CHAN_ACCEL_XYZ:
|
|
|
|
iis2dlpc_channel_get_acc(dev, chan, val);
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
LOG_DBG("Channel not supported");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int iis2dlpc_config(const struct device *dev, enum sensor_channel chan,
|
2020-02-12 15:31:46 +01:00
|
|
|
enum sensor_attribute attr,
|
|
|
|
const struct sensor_value *val)
|
|
|
|
{
|
|
|
|
switch (attr) {
|
|
|
|
case SENSOR_ATTR_FULL_SCALE:
|
2020-11-26 18:40:25 +01:00
|
|
|
return iis2dlpc_set_range(dev,
|
|
|
|
IIS2DLPC_FS_TO_REG(sensor_ms2_to_g(val)));
|
2020-02-12 15:31:46 +01:00
|
|
|
case SENSOR_ATTR_SAMPLING_FREQUENCY:
|
|
|
|
return iis2dlpc_set_odr(dev, val->val1);
|
|
|
|
default:
|
|
|
|
LOG_DBG("Acc attribute not supported");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int iis2dlpc_attr_set(const struct device *dev,
|
|
|
|
enum sensor_channel chan,
|
2020-02-12 15:31:46 +01:00
|
|
|
enum sensor_attribute attr,
|
|
|
|
const struct sensor_value *val)
|
|
|
|
{
|
|
|
|
switch (chan) {
|
|
|
|
case SENSOR_CHAN_ACCEL_X:
|
|
|
|
case SENSOR_CHAN_ACCEL_Y:
|
|
|
|
case SENSOR_CHAN_ACCEL_Z:
|
|
|
|
case SENSOR_CHAN_ACCEL_XYZ:
|
|
|
|
return iis2dlpc_config(dev, chan, attr, val);
|
|
|
|
default:
|
|
|
|
LOG_DBG("Attr not supported on %d channel", chan);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int iis2dlpc_sample_fetch(const struct device *dev,
|
|
|
|
enum sensor_channel chan)
|
2020-02-12 15:31:46 +01:00
|
|
|
{
|
2020-05-28 21:23:02 +02:00
|
|
|
struct iis2dlpc_data *iis2dlpc = dev->data;
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct iis2dlpc_device_config *cfg = dev->config;
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t shift;
|
2020-10-05 18:06:27 +02:00
|
|
|
int16_t buf[3];
|
2020-02-12 15:31:46 +01:00
|
|
|
|
|
|
|
/* fetch raw data sample */
|
2020-10-05 18:06:27 +02:00
|
|
|
if (iis2dlpc_acceleration_raw_get(iis2dlpc->ctx, buf) < 0) {
|
2020-02-12 15:31:46 +01:00
|
|
|
LOG_DBG("Failed to fetch raw data sample");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* adjust to resolution */
|
|
|
|
if (cfg->pm == IIS2DLPC_CONT_LOW_PWR_12bit) {
|
|
|
|
shift = IIS2DLPC_SHIFT_PM1;
|
|
|
|
} else {
|
|
|
|
shift = IIS2DLPC_SHIFT_PMOTHER;
|
|
|
|
}
|
|
|
|
|
2020-10-05 18:06:27 +02:00
|
|
|
iis2dlpc->acc[0] = sys_le16_to_cpu(buf[0]) >> shift;
|
|
|
|
iis2dlpc->acc[1] = sys_le16_to_cpu(buf[1]) >> shift;
|
|
|
|
iis2dlpc->acc[2] = sys_le16_to_cpu(buf[2]) >> shift;
|
2020-02-12 15:31:46 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct sensor_driver_api iis2dlpc_driver_api = {
|
|
|
|
.attr_set = iis2dlpc_attr_set,
|
|
|
|
#if CONFIG_IIS2DLPC_TRIGGER
|
|
|
|
.trigger_set = iis2dlpc_trigger_set,
|
|
|
|
#endif /* CONFIG_IIS2DLPC_TRIGGER */
|
|
|
|
.sample_fetch = iis2dlpc_sample_fetch,
|
|
|
|
.channel_get = iis2dlpc_channel_get,
|
|
|
|
};
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int iis2dlpc_init_interface(const struct device *dev)
|
2020-02-12 15:31:46 +01:00
|
|
|
{
|
2020-05-28 21:23:02 +02:00
|
|
|
struct iis2dlpc_data *iis2dlpc = dev->data;
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct iis2dlpc_device_config *cfg = dev->config;
|
2020-02-12 15:31:46 +01:00
|
|
|
|
|
|
|
iis2dlpc->bus = device_get_binding(cfg->bus_name);
|
|
|
|
if (!iis2dlpc->bus) {
|
|
|
|
LOG_DBG("master bus not found: %s", cfg->bus_name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2020-05-06 11:23:07 -07:00
|
|
|
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
2020-02-12 15:31:46 +01:00
|
|
|
iis2dlpc_spi_init(dev);
|
2020-05-06 11:23:07 -07:00
|
|
|
#elif DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
|
2020-02-12 15:31:46 +01:00
|
|
|
iis2dlpc_i2c_init(dev);
|
|
|
|
#else
|
|
|
|
#error "BUS MACRO NOT DEFINED IN DTS"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int iis2dlpc_set_power_mode(struct iis2dlpc_data *iis2dlpc,
|
|
|
|
iis2dlpc_mode_t pm)
|
|
|
|
{
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t regval = IIS2DLPC_CONT_LOW_PWR_12bit;
|
2020-02-12 15:31:46 +01:00
|
|
|
|
|
|
|
switch (pm) {
|
|
|
|
case IIS2DLPC_CONT_LOW_PWR_2:
|
|
|
|
case IIS2DLPC_CONT_LOW_PWR_3:
|
|
|
|
case IIS2DLPC_CONT_LOW_PWR_4:
|
|
|
|
case IIS2DLPC_HIGH_PERFORMANCE:
|
|
|
|
regval = pm;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
LOG_DBG("Apply default Power Mode");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return iis2dlpc_write_reg(iis2dlpc->ctx, IIS2DLPC_CTRL1, ®val, 1);
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int iis2dlpc_init(const struct device *dev)
|
2020-02-12 15:31:46 +01:00
|
|
|
{
|
2020-05-28 21:23:02 +02:00
|
|
|
struct iis2dlpc_data *iis2dlpc = dev->data;
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct iis2dlpc_device_config *cfg = dev->config;
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t wai;
|
2020-02-12 15:31:46 +01:00
|
|
|
|
|
|
|
if (iis2dlpc_init_interface(dev)) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check chip ID */
|
|
|
|
if (iis2dlpc_device_id_get(iis2dlpc->ctx, &wai) < 0) {
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wai != IIS2DLPC_ID) {
|
|
|
|
LOG_ERR("Invalid chip ID");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reset device */
|
|
|
|
if (iis2dlpc_reset_set(iis2dlpc->ctx, PROPERTY_ENABLE) < 0) {
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
k_busy_wait(100);
|
|
|
|
|
|
|
|
if (iis2dlpc_block_data_update_set(iis2dlpc->ctx,
|
|
|
|
PROPERTY_ENABLE) < 0) {
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set power mode */
|
2020-11-27 13:53:38 +01:00
|
|
|
LOG_INF("power-mode is %d", cfg->pm);
|
|
|
|
if (iis2dlpc_set_power_mode(iis2dlpc, cfg->pm)) {
|
2020-02-12 15:31:46 +01:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2020-11-26 21:17:22 +01:00
|
|
|
/* set default odr to 12.5Hz acc */
|
|
|
|
if (iis2dlpc_set_odr(dev, 12) < 0) {
|
|
|
|
LOG_ERR("odr init error (12.5 Hz)");
|
2020-02-12 15:31:46 +01:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2020-11-26 18:40:25 +01:00
|
|
|
LOG_INF("range is %d", cfg->range);
|
|
|
|
if (iis2dlpc_set_range(dev, IIS2DLPC_FS_TO_REG(cfg->range)) < 0) {
|
|
|
|
LOG_ERR("range init error %d", cfg->range);
|
2020-02-12 15:31:46 +01:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_IIS2DLPC_TRIGGER
|
|
|
|
if (iis2dlpc_init_interrupt(dev) < 0) {
|
|
|
|
LOG_ERR("Failed to initialize interrupts");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2021-01-15 20:37:27 +01:00
|
|
|
#ifdef CONFIG_IIS2DLPC_TAP
|
|
|
|
LOG_INF("TAP: tap mode is %d", cfg->tap_mode);
|
|
|
|
if (iis2dlpc_tap_mode_set(iis2dlpc->ctx, cfg->tap_mode) < 0) {
|
|
|
|
LOG_ERR("Failed to select tap trigger mode");
|
2020-02-12 15:31:46 +01:00
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2021-01-15 20:37:27 +01:00
|
|
|
LOG_INF("TAP: ths_x is %02x", cfg->tap_threshold[0]);
|
2020-02-12 15:31:46 +01:00
|
|
|
if (iis2dlpc_tap_threshold_x_set(iis2dlpc->ctx,
|
2021-01-15 20:37:27 +01:00
|
|
|
cfg->tap_threshold[0]) < 0) {
|
2020-02-12 15:31:46 +01:00
|
|
|
LOG_ERR("Failed to set tap X axis threshold");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2021-01-15 20:37:27 +01:00
|
|
|
LOG_INF("TAP: ths_y is %02x", cfg->tap_threshold[1]);
|
2020-02-12 15:31:46 +01:00
|
|
|
if (iis2dlpc_tap_threshold_y_set(iis2dlpc->ctx,
|
2021-01-15 20:37:27 +01:00
|
|
|
cfg->tap_threshold[1]) < 0) {
|
2020-02-12 15:31:46 +01:00
|
|
|
LOG_ERR("Failed to set tap Y axis threshold");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2021-01-15 20:37:27 +01:00
|
|
|
LOG_INF("TAP: ths_z is %02x", cfg->tap_threshold[2]);
|
2020-02-12 15:31:46 +01:00
|
|
|
if (iis2dlpc_tap_threshold_z_set(iis2dlpc->ctx,
|
2021-01-15 20:37:27 +01:00
|
|
|
cfg->tap_threshold[2]) < 0) {
|
2020-02-12 15:31:46 +01:00
|
|
|
LOG_ERR("Failed to set tap Z axis threshold");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2021-01-15 20:37:27 +01:00
|
|
|
if (cfg->tap_threshold[0] > 0) {
|
|
|
|
LOG_INF("TAP: tap_x enabled");
|
|
|
|
if (iis2dlpc_tap_detection_on_x_set(iis2dlpc->ctx, 1) < 0) {
|
|
|
|
LOG_ERR("Failed to set tap detection on X axis");
|
|
|
|
return -EIO;
|
|
|
|
}
|
2020-02-12 15:31:46 +01:00
|
|
|
}
|
|
|
|
|
2021-01-15 20:37:27 +01:00
|
|
|
if (cfg->tap_threshold[1] > 0) {
|
|
|
|
LOG_INF("TAP: tap_y enabled");
|
|
|
|
if (iis2dlpc_tap_detection_on_y_set(iis2dlpc->ctx, 1) < 0) {
|
|
|
|
LOG_ERR("Failed to set tap detection on Y axis");
|
|
|
|
return -EIO;
|
|
|
|
}
|
2020-02-12 15:31:46 +01:00
|
|
|
}
|
|
|
|
|
2021-01-15 20:37:27 +01:00
|
|
|
if (cfg->tap_threshold[2] > 0) {
|
|
|
|
LOG_INF("TAP: tap_z enabled");
|
|
|
|
if (iis2dlpc_tap_detection_on_z_set(iis2dlpc->ctx, 1) < 0) {
|
|
|
|
LOG_ERR("Failed to set tap detection on Z axis");
|
|
|
|
return -EIO;
|
|
|
|
}
|
2020-02-12 15:31:46 +01:00
|
|
|
}
|
|
|
|
|
2021-01-15 20:37:27 +01:00
|
|
|
LOG_INF("TAP: shock is %02x", cfg->tap_shock);
|
|
|
|
if (iis2dlpc_tap_shock_set(iis2dlpc->ctx, cfg->tap_shock) < 0) {
|
2020-02-12 15:31:46 +01:00
|
|
|
LOG_ERR("Failed to set tap shock duration");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2021-01-15 20:37:27 +01:00
|
|
|
LOG_INF("TAP: latency is %02x", cfg->tap_latency);
|
|
|
|
if (iis2dlpc_tap_dur_set(iis2dlpc->ctx, cfg->tap_latency) < 0) {
|
2020-02-12 15:31:46 +01:00
|
|
|
LOG_ERR("Failed to set tap latency");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2021-01-15 20:37:27 +01:00
|
|
|
LOG_INF("TAP: quiet time is %02x", cfg->tap_quiet);
|
|
|
|
if (iis2dlpc_tap_quiet_set(iis2dlpc->ctx, cfg->tap_quiet) < 0) {
|
2020-02-12 15:31:46 +01:00
|
|
|
LOG_ERR("Failed to set tap quiet time");
|
|
|
|
return -EIO;
|
|
|
|
}
|
2021-01-15 20:37:27 +01:00
|
|
|
#endif /* CONFIG_IIS2DLPC_TAP */
|
2020-02-12 15:31:46 +01:00
|
|
|
#endif /* CONFIG_IIS2DLPC_TRIGGER */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct iis2dlpc_device_config iis2dlpc_cfg = {
|
2020-03-26 16:47:47 -05:00
|
|
|
.bus_name = DT_INST_BUS_LABEL(0),
|
2020-11-27 13:53:38 +01:00
|
|
|
.pm = DT_INST_PROP(0, power_mode),
|
2020-11-26 18:40:25 +01:00
|
|
|
.range = DT_INST_PROP(0, range),
|
2020-02-12 15:31:46 +01:00
|
|
|
#ifdef CONFIG_IIS2DLPC_TRIGGER
|
2020-03-26 16:47:47 -05:00
|
|
|
.int_gpio_port = DT_INST_GPIO_LABEL(0, drdy_gpios),
|
|
|
|
.int_gpio_pin = DT_INST_GPIO_PIN(0, drdy_gpios),
|
|
|
|
.int_gpio_flags = DT_INST_GPIO_FLAGS(0, drdy_gpios),
|
2020-12-17 14:37:36 +01:00
|
|
|
.drdy_int = DT_INST_PROP(0, drdy_int),
|
|
|
|
|
2021-01-15 20:37:27 +01:00
|
|
|
#ifdef CONFIG_IIS2DLPC_TAP
|
|
|
|
.tap_mode = DT_INST_PROP(0, tap_mode),
|
|
|
|
.tap_threshold = DT_INST_PROP(0, tap_threshold),
|
|
|
|
.tap_shock = DT_INST_PROP(0, tap_shock),
|
|
|
|
.tap_latency = DT_INST_PROP(0, tap_latency),
|
|
|
|
.tap_quiet = DT_INST_PROP(0, tap_quiet),
|
|
|
|
#endif /* CONFIG_IIS2DLPC_TAP */
|
2020-02-12 15:31:46 +01:00
|
|
|
#endif /* CONFIG_IIS2DLPC_TRIGGER */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iis2dlpc_data iis2dlpc_data;
|
|
|
|
|
2020-12-15 18:53:48 -06:00
|
|
|
DEVICE_DT_INST_DEFINE(0, iis2dlpc_init, device_pm_control_nop,
|
2020-02-12 15:31:46 +01:00
|
|
|
&iis2dlpc_data, &iis2dlpc_cfg, POST_KERNEL,
|
|
|
|
CONFIG_SENSOR_INIT_PRIORITY, &iis2dlpc_driver_api);
|