Lines Matching +full:no +full:- +full:auto +full:- +full:reset

4  * SPDX-License-Identifier: Apache-2.0
113 const struct si7210_config *config = dev->config; in si7210_sleep()
114 struct si7210_data *data = dev->data; in si7210_sleep()
119 * the register, but they get reloaded from OTP during wake-up. in si7210_sleep()
121 rc = i2c_reg_write_byte_dt(&config->bus, SI7210_REG_CTRL3, 0); in si7210_sleep()
128 rc = i2c_reg_write_byte_dt(&config->bus, SI7210_REG_POWER_CTRL, in si7210_sleep()
136 data->reg_dspsigsel = 0x00; in si7210_sleep()
137 data->reg_arautoinc = 0x00; in si7210_sleep()
145 const struct si7210_config *config = dev->config; in si7210_wakeup()
154 rc = i2c_read_dt(&config->bus, &val, 1); in si7210_wakeup()
156 LOG_ERR("Failed to go wake-up chip"); in si7210_wakeup()
164 * The Si7210 device do not have a reset function, but most of the registers
184 const struct si7210_config *config = dev->config; in si7210_otp_reg_read_byte()
187 rc = i2c_reg_write_byte_dt(&config->bus, SI7210_REG_OTP_ADDR, otp_reg_addr); in si7210_otp_reg_read_byte()
193 rc = i2c_reg_write_byte_dt(&config->bus, SI7210_REG_OTP_CTRL, SI7210_BIT_OTP_CTRL_READEN); in si7210_otp_reg_read_byte()
200 * No need to check for the data availability (SI7210_REG_OTP_CTRL, bit in si7210_otp_reg_read_byte()
204 rc = i2c_reg_read_byte_dt(&config->bus, SI7210_REG_OTP_DATA, value); in si7210_otp_reg_read_byte()
237 const struct si7210_config *config = dev->config; in si7210_set_dspsigsel()
238 struct si7210_data *data = dev->data; in si7210_set_dspsigsel()
241 if (data->reg_dspsigsel == value) { in si7210_set_dspsigsel()
245 rc = i2c_reg_write_byte_dt(&config->bus, SI7210_REG_DSPSIGSEL, value); in si7210_set_dspsigsel()
251 data->reg_dspsigsel = value; in si7210_set_dspsigsel()
259 const struct si7210_config *config = dev->config; in si7210_set_arautoinc()
260 struct si7210_data *data = dev->data; in si7210_set_arautoinc()
263 if (data->reg_arautoinc == value) { in si7210_set_arautoinc()
267 rc = i2c_reg_write_byte_dt(&config->bus, SI7210_REG_ARAUTOINC, value); in si7210_set_arautoinc()
269 LOG_ERR("Failed to set the auto increment register"); in si7210_set_arautoinc()
273 data->reg_arautoinc = value; in si7210_set_arautoinc()
280 const struct si7210_config *config = dev->config; in si7210_sample_fetch_one()
290 /* Enable auto increment to be able to read DSPSIGM and DSPSIGL sequentially */ in si7210_sample_fetch_one()
297 rc = i2c_reg_write_byte_dt(&config->bus, SI7210_REG_POWER_CTRL, in si7210_sample_fetch_one()
305 * No need to wait for the conversion to end, the I2C bus guarantees in si7210_sample_fetch_one()
309 /* Read DSPSIG in one burst as auto increment is enabled */ in si7210_sample_fetch_one()
310 rc = i2c_burst_read_dt(&config->bus, SI7210_REG_DSPSIGM, (uint8_t *)&val, sizeof(val)); in si7210_sample_fetch_one()
323 struct si7210_data *data = dev->data; in si7210_sample_fetch()
336 return -EIO; in si7210_sample_fetch()
349 data->temp_sample = dspsig >> 3; in si7210_sample_fetch()
359 data->mag_sample = dspsig; in si7210_sample_fetch()
372 struct si7210_data *data = dev->data; in si7210_channel_get()
378 tmp = data->temp_sample; in si7210_channel_get()
380 /* temperature_raw = -3.83e-6 * value^2 + 0.16094 * value - 279.80 */ in si7210_channel_get()
381 tmp = (-383 * tmp * tmp) / 100 + (160940 * tmp) - 279800000; in si7210_channel_get()
384 tmp = (tmp * (2048 + data->otp_temp_gain)) / 2048; in si7210_channel_get()
385 tmp = tmp + (data->otp_temp_offset * 62500); in si7210_channel_get()
388 * Additional offset of -0.222 x VDD. The datasheet recommends in si7210_channel_get()
391 tmp -= 732600; in si7210_channel_get()
393 val->val1 = tmp / 1000000; in si7210_channel_get()
394 val->val2 = tmp % 1000000; in si7210_channel_get()
398 tmp = data->mag_sample; in si7210_channel_get()
400 if (data->scale == si7210_scale_200G) { in si7210_channel_get()
402 * Formula in mT (datasheet) for the 20mT scale: (value - 16384) * 0.00125 in si7210_channel_get()
403 * => Formula in G for the 200G scale: (value - 16384) * 0.0125 in si7210_channel_get()
405 tmp = (tmp - 16384) * 12500; in si7210_channel_get()
408 * Formula in mT (datasheet) for the 200mT scale: (value - 16384) * 0.0125 in si7210_channel_get()
409 * => Formula in G for the 2000G scale: (value - 16384) * 0.125 in si7210_channel_get()
411 tmp = (tmp - 16384) * 1250; in si7210_channel_get()
414 val->val1 = tmp / 1000000; in si7210_channel_get()
415 val->val2 = tmp % 1000000; in si7210_channel_get()
418 return -ENOTSUP; in si7210_channel_get()
437 /* Wake-up the chip */ in si7210_pm_action()
445 return -ENOTSUP; in si7210_pm_action()
454 const struct si7210_config *config = dev->config; in si7210_init()
455 struct si7210_data *data = dev->data; in si7210_init()
461 if (!device_is_ready(config->bus.bus)) { in si7210_init()
462 LOG_ERR("I2C bus %s not ready!", config->bus.bus->name); in si7210_init()
463 return -ENODEV; in si7210_init()
469 LOG_ERR("Failed to wake-up device"); in si7210_init()
474 rc = i2c_reg_read_byte_dt(&config->bus, SI7210_REG_CHIPID, &chipid); in si7210_init()
482 return -EINVAL; in si7210_init()
509 LOG_INF("Found Si72%02d-%c-%02d S/N %08x, at I2C address 0x%x", in si7210_init()
510 part_base, rev, part_variant, sn, config->bus.addr); in si7210_init()
513 data->scale = (part_variant == 5 || part_variant == 15) ? in si7210_init()
517 rc = si7210_otp_reg_read_byte(dev, SI7210_OTPREG_TEMP_OFFSET, &data->otp_temp_offset); in si7210_init()
521 rc = si7210_otp_reg_read_byte(dev, SI7210_OTPREG_TEMP_GAIN, &data->otp_temp_gain); in si7210_init()
526 /* Reset the device */ in si7210_init()
529 LOG_ERR("Failed to reset the device"); in si7210_init()