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

1 /* ST Microelectronics LIS2DH 3-axis accelerometer driver
5 * SPDX-License-Identifier: Apache-2.0
17 #if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
26 static int lis2dh_raw_read(const struct device *dev, uint8_t reg_addr, in lis2dh_raw_read() argument
29 const struct lis2dh_config *cfg = dev->config; in lis2dh_raw_read()
56 return -EIO; in lis2dh_raw_read()
63 if (spi_transceive_dt(&cfg->bus_cfg.spi, &tx, &rx)) { in lis2dh_raw_read()
64 return -EIO; in lis2dh_raw_read()
70 static int lis2dh_raw_write(const struct device *dev, uint8_t reg_addr, in lis2dh_raw_write() argument
73 const struct lis2dh_config *cfg = dev->config; in lis2dh_raw_write()
92 return -EIO; in lis2dh_raw_write()
99 if (spi_write_dt(&cfg->bus_cfg.spi, &tx)) { in lis2dh_raw_write()
100 return -EIO; in lis2dh_raw_write()
106 static int lis2dh_spi_read_data(const struct device *dev, uint8_t reg_addr, in lis2dh_spi_read_data() argument
109 return lis2dh_raw_read(dev, reg_addr, value, len); in lis2dh_spi_read_data()
112 static int lis2dh_spi_write_data(const struct device *dev, uint8_t reg_addr, in lis2dh_spi_write_data() argument
115 return lis2dh_raw_write(dev, reg_addr, value, len); in lis2dh_spi_write_data()
118 static int lis2dh_spi_read_reg(const struct device *dev, uint8_t reg_addr, in lis2dh_spi_read_reg() argument
121 return lis2dh_raw_read(dev, reg_addr, value, 1); in lis2dh_spi_read_reg()
124 static int lis2dh_spi_write_reg(const struct device *dev, uint8_t reg_addr, in lis2dh_spi_write_reg() argument
129 return lis2dh_raw_write(dev, reg_addr, &tmp_val, 1); in lis2dh_spi_write_reg()
132 static int lis2dh_spi_update_reg(const struct device *dev, uint8_t reg_addr, in lis2dh_spi_update_reg() argument
137 lis2dh_raw_read(dev, reg_addr, &tmp_val, 1); in lis2dh_spi_update_reg()
140 return lis2dh_raw_write(dev, reg_addr, &tmp_val, 1); in lis2dh_spi_update_reg()
151 int lis2dh_spi_init(const struct device *dev) in lis2dh_spi_init() argument
153 struct lis2dh_data *data = dev->data; in lis2dh_spi_init()
154 const struct lis2dh_config *cfg = dev->config; in lis2dh_spi_init()
156 data->hw_tf = &lis2dh_spi_transfer_fn; in lis2dh_spi_init()
158 if (!spi_is_ready_dt(&cfg->bus_cfg.spi)) { in lis2dh_spi_init()
159 LOG_ERR("SPI bus is not ready"); in lis2dh_spi_init()
160 return -ENODEV; in lis2dh_spi_init()
165 #endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) */