drivers/sensor: lsm6dso: Refactor common config out of I2C/SPI macros
Move common settings out of the SPI and I2C instantiation macros and into a common macro, which the aforementioned two macros can then use. Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
This commit is contained in:
parent
c269692b1d
commit
5edd4221ad
1 changed files with 12 additions and 16 deletions
|
@ -876,6 +876,16 @@ static int lsm6dso_init(const struct device *dev)
|
||||||
SPI_MODE_CPOL | \
|
SPI_MODE_CPOL | \
|
||||||
SPI_MODE_CPHA) \
|
SPI_MODE_CPHA) \
|
||||||
|
|
||||||
|
#define LSM6DSO_CONFIG_COMMON(inst) \
|
||||||
|
.accel_pm = DT_INST_PROP(inst, accel_pm), \
|
||||||
|
.accel_odr = DT_INST_PROP(inst, accel_odr), \
|
||||||
|
.accel_range = DT_INST_PROP(inst, accel_range), \
|
||||||
|
.gyro_pm = DT_INST_PROP(inst, gyro_pm), \
|
||||||
|
.gyro_odr = DT_INST_PROP(inst, gyro_odr), \
|
||||||
|
.gyro_range = DT_INST_PROP(inst, gyro_range), \
|
||||||
|
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
||||||
|
(LSM6DSO_CFG_IRQ(inst)), ())
|
||||||
|
|
||||||
#define LSM6DSO_CONFIG_SPI(inst) \
|
#define LSM6DSO_CONFIG_SPI(inst) \
|
||||||
{ \
|
{ \
|
||||||
.ctx = { \
|
.ctx = { \
|
||||||
|
@ -891,14 +901,7 @@ static int lsm6dso_init(const struct device *dev)
|
||||||
LSM6DSO_SPI_OP, \
|
LSM6DSO_SPI_OP, \
|
||||||
0), \
|
0), \
|
||||||
}, \
|
}, \
|
||||||
.accel_pm = DT_INST_PROP(inst, accel_pm), \
|
LSM6DSO_CONFIG_COMMON(inst) \
|
||||||
.accel_odr = DT_INST_PROP(inst, accel_odr), \
|
|
||||||
.accel_range = DT_INST_PROP(inst, accel_range), \
|
|
||||||
.gyro_pm = DT_INST_PROP(inst, gyro_pm), \
|
|
||||||
.gyro_odr = DT_INST_PROP(inst, gyro_odr), \
|
|
||||||
.gyro_range = DT_INST_PROP(inst, gyro_range), \
|
|
||||||
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
|
||||||
(LSM6DSO_CFG_IRQ(inst)), ()) \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -918,14 +921,7 @@ static int lsm6dso_init(const struct device *dev)
|
||||||
.stmemsc_cfg = { \
|
.stmemsc_cfg = { \
|
||||||
.i2c = I2C_DT_SPEC_INST_GET(inst), \
|
.i2c = I2C_DT_SPEC_INST_GET(inst), \
|
||||||
}, \
|
}, \
|
||||||
.accel_pm = DT_INST_PROP(inst, accel_pm), \
|
LSM6DSO_CONFIG_COMMON(inst) \
|
||||||
.accel_odr = DT_INST_PROP(inst, accel_odr), \
|
|
||||||
.accel_range = DT_INST_PROP(inst, accel_range), \
|
|
||||||
.gyro_pm = DT_INST_PROP(inst, gyro_pm), \
|
|
||||||
.gyro_odr = DT_INST_PROP(inst, gyro_odr), \
|
|
||||||
.gyro_range = DT_INST_PROP(inst, gyro_range), \
|
|
||||||
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
|
|
||||||
(LSM6DSO_CFG_IRQ(inst)), ()) \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue