drivers: sensor: bmp388: convert to spi_dt_spec
Convert bmp388 driver to use spi_dt_spec helpers. Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
This commit is contained in:
parent
022bc83351
commit
0a7d8d4452
2 changed files with 8 additions and 8 deletions
|
@ -52,7 +52,7 @@ static int bmp388_transceive(const struct device *dev,
|
||||||
const struct spi_buf buf = { .buf = data, .len = length };
|
const struct spi_buf buf = { .buf = data, .len = length };
|
||||||
const struct spi_buf_set s = { .buffers = &buf, .count = 1 };
|
const struct spi_buf_set s = { .buffers = &buf, .count = 1 };
|
||||||
|
|
||||||
return spi_transceive(cfg->bus, &cfg->spi_cfg, &s, &s);
|
return spi_transceive_dt(&cfg->spi_bus, &s, &s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bmp388_read_spi(const struct device *dev,
|
static int bmp388_read_spi(const struct device *dev,
|
||||||
|
@ -71,7 +71,7 @@ static int bmp388_read_spi(const struct device *dev,
|
||||||
const struct spi_buf_set tx = { .buffers = buf, .count = 1 };
|
const struct spi_buf_set tx = { .buffers = buf, .count = 1 };
|
||||||
const struct spi_buf_set rx = { .buffers = buf, .count = 2 };
|
const struct spi_buf_set rx = { .buffers = buf, .count = 2 };
|
||||||
|
|
||||||
return spi_transceive(cfg->bus, &cfg->spi_cfg, &tx, &rx);
|
return spi_transceive_dt(&cfg->spi_bus, &tx, &rx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bmp388_byte_read_spi(const struct device *dev,
|
static int bmp388_byte_read_spi(const struct device *dev,
|
||||||
|
@ -602,10 +602,10 @@ static int bmp388_init(const struct device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
||||||
/* Verify that the CS device is ready if it is set in the DT. */
|
/* Verify the SPI bus */
|
||||||
if (is_spi && (cfg->spi_cfg.cs != NULL)) {
|
if (is_spi) {
|
||||||
if (!device_is_ready(cfg->spi_cfg.cs->gpio_dev)) {
|
if (!spi_is_ready(&cfg->spi_bus)) {
|
||||||
LOG_ERR("SPI CS device is not ready");
|
LOG_ERR("SPI bus is not ready");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -694,7 +694,7 @@ static int bmp388_init(const struct device *dev)
|
||||||
|
|
||||||
#define BMP388_BUS_CFG_SPI(inst) \
|
#define BMP388_BUS_CFG_SPI(inst) \
|
||||||
.ops = &bmp388_spi_ops, \
|
.ops = &bmp388_spi_ops, \
|
||||||
.spi_cfg = SPI_CONFIG_DT_INST(inst, SPI_OP_MODE_MASTER | SPI_WORD_SET(8), 0)
|
.spi_bus = SPI_DT_SPEC_INST_GET(inst, SPI_OP_MODE_MASTER | SPI_WORD_SET(8), 0)
|
||||||
|
|
||||||
#define BMP388_BUS_CFG(inst) \
|
#define BMP388_BUS_CFG(inst) \
|
||||||
COND_CODE_1(DT_INST_ON_BUS(inst, i2c), \
|
COND_CODE_1(DT_INST_ON_BUS(inst, i2c), \
|
||||||
|
|
|
@ -143,7 +143,7 @@ struct bmp388_config {
|
||||||
const struct bmp388_io_ops *ops;
|
const struct bmp388_io_ops *ops;
|
||||||
union {
|
union {
|
||||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
|
||||||
struct spi_config spi_cfg;
|
struct spi_dt_spec spi_bus;
|
||||||
#endif
|
#endif
|
||||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
|
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
|
||||||
uint16_t bus_addr;
|
uint16_t bus_addr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue