Lines Matching +full:spi +full:- +full:dev

1 /* ST Microelectronics IIS2MDC 3-axis magnetometer sensor
5 * SPDX-License-Identifier: Apache-2.0
17 #if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
23 static int iis2mdc_spi_read(const struct device *dev, uint8_t reg, in iis2mdc_spi_read() argument
26 const struct iis2mdc_dev_config *cfg = dev->config; in iis2mdc_spi_read()
52 return -EIO; in iis2mdc_spi_read()
55 if (spi_transceive_dt(&cfg->spi, &tx, &rx)) { in iis2mdc_spi_read()
56 return -EIO; in iis2mdc_spi_read()
62 static int iis2mdc_spi_write(const struct device *dev, uint8_t reg, in iis2mdc_spi_write() argument
65 const struct iis2mdc_dev_config *cfg = dev->config; in iis2mdc_spi_write()
83 return -EIO; in iis2mdc_spi_write()
86 if (spi_write_dt(&cfg->spi, &tx)) { in iis2mdc_spi_write()
87 return -EIO; in iis2mdc_spi_write()
93 int iis2mdc_spi_init(const struct device *dev) in iis2mdc_spi_init() argument
95 struct iis2mdc_data *data = dev->data; in iis2mdc_spi_init()
96 const struct iis2mdc_dev_config *const cfg = dev->config; in iis2mdc_spi_init()
98 if (!spi_is_ready_dt(&cfg->spi)) { in iis2mdc_spi_init()
99 LOG_ERR("SPI bus is not ready"); in iis2mdc_spi_init()
100 return -ENODEV; in iis2mdc_spi_init()
103 data->ctx_spi.read_reg = (stmdev_read_ptr) iis2mdc_spi_read; in iis2mdc_spi_init()
104 data->ctx_spi.write_reg = (stmdev_write_ptr) iis2mdc_spi_write; in iis2mdc_spi_init()
105 data->ctx_spi.mdelay = (stmdev_mdelay_ptr) stmemsc_mdelay; in iis2mdc_spi_init()
107 data->ctx = &data->ctx_spi; in iis2mdc_spi_init()
108 data->ctx->handle = (void *)dev; in iis2mdc_spi_init()
112 #endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) */