Lines Matching +full:reset +full:- +full:val

4  * SPDX-License-Identifier: Apache-2.0
28 const struct fxas21002_config *cfg = dev->config; in fxas21002_transceive()
32 return spi_transceive_dt(&cfg->bus_cfg.spi, &s, &s); in fxas21002_transceive()
40 const struct fxas21002_config *cfg = dev->config; in fxas21002_read_spi()
51 return spi_transceive_dt(&cfg->bus_cfg.spi, &tx, &rx); in fxas21002_read_spi()
81 uint8_t val) in fxas21002_reg_field_update_spi() argument
91 return fxas21002_byte_write_spi(dev, reg, (old_val & ~mask) | (val & mask)); in fxas21002_reg_field_update_spi()
108 const struct fxas21002_config *config = dev->config; in fxas21002_read_i2c()
110 return i2c_burst_read_dt(&config->bus_cfg.i2c, reg, data, length); in fxas21002_read_i2c()
117 const struct fxas21002_config *config = dev->config; in fxas21002_byte_read_i2c()
119 return i2c_reg_read_byte_dt(&config->bus_cfg.i2c, reg, byte); in fxas21002_byte_read_i2c()
126 const struct fxas21002_config *config = dev->config; in fxas21002_byte_write_i2c()
128 return i2c_reg_write_byte_dt(&config->bus_cfg.i2c, reg, byte); in fxas21002_byte_write_i2c()
134 uint8_t val) in fxas21002_reg_field_update_i2c() argument
136 const struct fxas21002_config *config = dev->config; in fxas21002_reg_field_update_i2c()
138 return i2c_reg_update_byte_dt(&config->bus_cfg.i2c, reg, mask, val); in fxas21002_reg_field_update_i2c()
151 const struct fxas21002_config *config = dev->config; in fxas21002_sample_fetch()
152 struct fxas21002_data *data = dev->data; in fxas21002_sample_fetch()
160 return -ENOTSUP; in fxas21002_sample_fetch()
163 k_sem_take(&data->sem, K_FOREVER); in fxas21002_sample_fetch()
166 if (config->ops->read(dev, FXAS21002_REG_OUTXMSB, buffer, in fxas21002_sample_fetch()
169 ret = -EIO; in fxas21002_sample_fetch()
173 /* Parse the buffer into raw channel data (16-bit integers). To save in fxas21002_sample_fetch()
177 raw = &data->raw[0]; in fxas21002_sample_fetch()
184 k_sem_give(&data->sem); in fxas21002_sample_fetch()
189 static void fxas21002_convert(struct sensor_value *val, int16_t raw, in fxas21002_convert() argument
199 val->val1 = micro_rad / 1000000; in fxas21002_convert()
200 val->val2 = micro_rad % 1000000; in fxas21002_convert()
205 struct sensor_value *val) in fxas21002_channel_get() argument
207 const struct fxas21002_config *config = dev->config; in fxas21002_channel_get()
208 struct fxas21002_data *data = dev->data; in fxas21002_channel_get()
215 k_sem_take(&data->sem, K_FOREVER); in fxas21002_channel_get()
220 ret = -ENOTSUP; in fxas21002_channel_get()
246 raw = &data->raw[start_channel]; in fxas21002_channel_get()
248 fxas21002_convert(val++, *raw++, config->range); in fxas21002_channel_get()
259 k_sem_give(&data->sem); in fxas21002_channel_get()
266 const struct fxas21002_config *config = dev->config; in fxas21002_get_power()
267 uint8_t val = *power; in fxas21002_get_power() local
269 if (config->ops->byte_read(dev, FXAS21002_REG_CTRLREG1, &val)) { in fxas21002_get_power()
271 return -EIO; in fxas21002_get_power()
273 val &= FXAS21002_CTRLREG1_POWER_MASK; in fxas21002_get_power()
274 *power = val; in fxas21002_get_power()
281 const struct fxas21002_config *config = dev->config; in fxas21002_set_power()
283 return config->ops->reg_field_update(dev, FXAS21002_REG_CTRLREG1, in fxas21002_set_power()
314 const struct fxas21002_config *config = dev->config; in fxas21002_init()
315 struct fxas21002_data *data = dev->data; in fxas21002_init()
322 if (config->inst_on_bus == FXAS21002_BUS_I2C) { in fxas21002_init()
323 if (!device_is_ready(config->bus_cfg.i2c.bus)) { in fxas21002_init()
325 return -ENODEV; in fxas21002_init()
331 if (config->inst_on_bus == FXAS21002_BUS_SPI) { in fxas21002_init()
332 if (!device_is_ready(config->bus_cfg.spi.bus)) { in fxas21002_init()
334 return -ENODEV; in fxas21002_init()
337 if (config->reset_gpio.port) { in fxas21002_init()
338 /* Pulse RST pin high to perform a hardware reset of in fxas21002_init()
341 if (!gpio_is_ready_dt(&config->reset_gpio)) { in fxas21002_init()
343 return -ENODEV; in fxas21002_init()
346 gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT_INACTIVE); in fxas21002_init()
348 gpio_pin_set_dt(&config->reset_gpio, 1); in fxas21002_init()
350 * the RST pin high in order to reset. Stay on the in fxas21002_init()
354 gpio_pin_set_dt(&config->reset_gpio, 0); in fxas21002_init()
364 if (config->ops->byte_read(dev, FXAS21002_REG_WHOAMI, &whoami)) { in fxas21002_init()
366 return -EIO; in fxas21002_init()
369 if (whoami != config->whoami) { in fxas21002_init()
371 whoami, config->whoami); in fxas21002_init()
372 return -EIO; in fxas21002_init()
376 if (config->inst_on_bus == FXAS21002_BUS_I2C) { in fxas21002_init()
377 /* Reset the sensor. Upon issuing a software reset command over the I2C in fxas21002_init()
382 config->ops->byte_write(dev, FXAS21002_REG_CTRLREG1, in fxas21002_init()
385 /* Wait for the reset sequence to complete */ in fxas21002_init()
387 if (config->ops->byte_read(dev, FXAS21002_REG_CTRLREG1, in fxas21002_init()
390 return -EIO; in fxas21002_init()
396 /* Set the full-scale range */ in fxas21002_init()
397 if (config->ops->reg_field_update(dev, FXAS21002_REG_CTRLREG0, in fxas21002_init()
398 FXAS21002_CTRLREG0_FS_MASK, config->range)) { in fxas21002_init()
400 return -EIO; in fxas21002_init()
404 if (config->ops->reg_field_update(dev, FXAS21002_REG_CTRLREG1, in fxas21002_init()
406 config->dr << FXAS21002_CTRLREG1_DR_SHIFT)) { in fxas21002_init()
408 return -EIO; in fxas21002_init()
411 k_sem_init(&data->sem, 0, K_SEM_MAX_LIMIT); in fxas21002_init()
414 if (config->int_gpio.port) { in fxas21002_init()
417 return -EIO; in fxas21002_init()
425 return -EIO; in fxas21002_init()
431 config->dr); in fxas21002_init()
433 k_sem_give(&data->sem); in fxas21002_init()