Skip to content

Commit

Permalink
drivers/sensor/lsm6dsl: Use DT defines to select I2C/SPI bus
Browse files Browse the repository at this point in the history
Remove configuration parameter CONFIG_BUS_TYPE. Now we may
make use of DT_ST_LSM6DSL_BUS_I2C and DT_ST_LSM6DSL_BUS_SPI
definition to select the bus.

Signed-off-by: Armando Visconti <[email protected]>
  • Loading branch information
avisconti authored and galak committed Jan 8, 2019
1 parent d1ed336 commit f300ded
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 23 deletions.
4 changes: 0 additions & 4 deletions boards/arm/96b_argonkey/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ endif # DMA

if LSM6DSL

choice LSM6DSL_BUS_TYPE
default LSM6DSL_SPI
endchoice

choice LSM6DSL_TRIGGER_MODE
default LSM6DSL_TRIGGER_GLOBAL_THREAD
endchoice
Expand Down
4 changes: 2 additions & 2 deletions drivers/sensor/lsm6dsl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
zephyr_library()

zephyr_library_sources_ifdef(CONFIG_LSM6DSL lsm6dsl.c)
zephyr_library_sources_ifdef(CONFIG_LSM6DSL_SPI lsm6dsl_spi.c)
zephyr_library_sources_ifdef(CONFIG_LSM6DSL_I2C lsm6dsl_i2c.c)
zephyr_library_sources_ifdef(CONFIG_LSM6DSL lsm6dsl_spi.c)
zephyr_library_sources_ifdef(CONFIG_LSM6DSL lsm6dsl_i2c.c)
zephyr_library_sources_ifdef(CONFIG_LSM6DSL_TRIGGER lsm6dsl_trigger.c)
zephyr_library_sources_ifdef(CONFIG_LSM6DSL_SENSORHUB lsm6dsl_shub.c)
15 changes: 0 additions & 15 deletions drivers/sensor/lsm6dsl/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@ menuconfig LSM6DSL

if LSM6DSL

choice LSM6DSL_BUS_TYPE
prompt "Interface to AP"
help
Select interface the LSM6DSL driver is connected to AP

config LSM6DSL_I2C
depends on I2C
bool "I2C Interface"

config LSM6DSL_SPI
depends on SPI
bool "SPI Interface"

endchoice

choice LSM6DSL_TRIGGER_MODE
prompt "Trigger mode"
help
Expand Down
4 changes: 2 additions & 2 deletions drivers/sensor/lsm6dsl/lsm6dsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ static int lsm6dsl_init_chip(struct device *dev)
}

static struct lsm6dsl_config lsm6dsl_config = {
#ifdef CONFIG_LSM6DSL_SPI
#ifdef DT_ST_LSM6DSL_BUS_SPI
.comm_master_dev_name = DT_LSM6DSL_SPI_MASTER_DEV_NAME,
#else
.comm_master_dev_name = DT_LSM6DSL_I2C_MASTER_DEV_NAME,
Expand All @@ -792,7 +792,7 @@ static int lsm6dsl_init(struct device *dev)
return -EINVAL;
}

#ifdef CONFIG_LSM6DSL_SPI
#ifdef DT_ST_LSM6DSL_BUS_SPI
lsm6dsl_spi_init(dev);
#else
lsm6dsl_i2c_init(dev);
Expand Down
3 changes: 3 additions & 0 deletions drivers/sensor/lsm6dsl/lsm6dsl_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include "lsm6dsl.h"

#ifdef DT_ST_LSM6DSL_BUS_I2C

static u16_t lsm6dsl_i2c_slave_addr = DT_LSM6DSL_I2C_ADDR;

#define LOG_LEVEL CONFIG_SENSOR_LOG_LEVEL
Expand Down Expand Up @@ -61,3 +63,4 @@ int lsm6dsl_i2c_init(struct device *dev)

return 0;
}
#endif /* DT_ST_LSM6DSL_BUS_I2C */
3 changes: 3 additions & 0 deletions drivers/sensor/lsm6dsl/lsm6dsl_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "lsm6dsl.h"
#include <logging/log.h>

#ifdef DT_ST_LSM6DSL_BUS_SPI

#define LSM6DSL_SPI_READ (1 << 7)

#define LOG_LEVEL CONFIG_SENSOR_LOG_LEVEL
Expand Down Expand Up @@ -168,3 +170,4 @@ int lsm6dsl_spi_init(struct device *dev)

return 0;
}
#endif /* DT_ST_LSM6DSL_BUS_SPI */
1 change: 1 addition & 0 deletions tests/drivers/build_all/dts_fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
#define DT_LSM6DSL_I2C_MASTER_DEV_NAME ""
#define DT_LSM6DSL_GPIO_DEV_NAME ""
#define DT_LSM6DSL_GPIO_PIN_NUM 0
#define DT_ST_LSM6DSL_BUS_I2C 1
#endif

#ifndef DT_LPS22HB_DEV_NAME
Expand Down

0 comments on commit f300ded

Please sign in to comment.