Lines Matching +full:settling +full:- +full:time

1 /* fdc2x1x.c - Driver for the Texas Instruments FDC2X1X */
6 * SPDX-License-Identifier: Apache-2.0
26 * @param dev - The device structure.
27 * @param ch - Channel to convert the data from.
28 * @param freq - Calculated frequency value .
33 struct fdc2x1x_data *data = dev->data; in fdc2x1x_raw_to_freq()
34 const struct fdc2x1x_config *cfg = dev->config; in fdc2x1x_raw_to_freq()
36 if (data->fdc221x) { in fdc2x1x_raw_to_freq()
37 *freq = (cfg->ch_cfg->fin_sel * (cfg->fref / 1000.0) * in fdc2x1x_raw_to_freq()
38 data->channel_buf[ch]) / pow(2, 28); in fdc2x1x_raw_to_freq()
40 *freq = cfg->ch_cfg->fin_sel * (cfg->fref / 1000.0) * in fdc2x1x_raw_to_freq()
41 ((data->channel_buf[ch] / pow(2, 12 + cfg->output_gain)) + in fdc2x1x_raw_to_freq()
42 (cfg->ch_cfg[ch].offset / pow(2, 16))); in fdc2x1x_raw_to_freq()
49 * @param dev - The device structure.
50 * @param ch - Channel to convert the data from .
51 * @param freq - Frequency value
52 * @param capacitance - Calculated capacitance value
57 const struct fdc2x1x_config *cfg = dev->config; in fdc2x1x_raw_to_capacitance()
59 *capacitance = 1 / ((cfg->ch_cfg->inductance / 1000000.0) * in fdc2x1x_raw_to_capacitance()
65 * @param dev - The device structure.
66 * @param reg - The register address. Use FDC2X1X_REG_READ(x) or
68 * @param data - The register data.
69 * @param length - Number of bytes being read
75 const struct fdc2x1x_config *cfg = dev->config; in fdc2x1x_bus_access()
78 return i2c_burst_read_dt(&cfg->i2c, FDC2X1X_TO_I2C_REG(reg), data, length); in fdc2x1x_bus_access()
81 return -EINVAL; in fdc2x1x_bus_access()
89 return i2c_write_dt(&cfg->i2c, buf, sizeof(buf)); in fdc2x1x_bus_access()
95 * @param dev - The device structure.
96 * @param reg_addr - The register address.
97 * @param reg_data - The register data.
115 * @param dev - The device structure.
116 * @param reg_addr - The register address.
117 * @param reg_data - The register data.
136 * @param dev - The device structure.
137 * @param reg_addr - The register address.
138 * @param mask - The mask.
139 * @param data - The register data.
165 * @param dev - The device structure.
166 * @param chx - Channel number.
167 * @param fin_sel - Frequency selection value.
181 * @param dev - The device structure.
182 * @param chx - Channel number.
183 * @param fref_div - Reference divider value.
197 * @param dev - The device structure.
198 * @param chx - Channel number.
199 * @param idrv - Sensor driver current.
212 * Set the Conversion Settling value of a specific channel.
213 * @param dev - The device structure.
214 * @param chx - Channel number.
215 * @param settle_count - Settling time value.
227 * @param dev - The device structure.
228 * @param chx - Channel number.
229 * @param rcount - Reference count value.
241 * @param dev - The device structure.
242 * @param chx - Channel number.
243 * @param offset - Offset value.
253 * Set the Auto-Scan Mode.
254 * @param dev - The device structure.
255 * @param en - Enable/disable auto-scan mode.
267 * Set the Auto-Scan Sequence Configuration.
268 * @param dev - The device structure.
269 * @param rr_seq - Auto-Scan sequence value.
282 * @param dev - The device structure.
283 * @param deglitch - Deglitch selection.
296 * @param dev - The device structure.
297 * @param gain - Output gain.
310 * conversion if Auto-Scan Mode is disabled.
311 * @param dev - The device structure.
312 * @param ch - Active channel.
325 * @param dev - The device structure.
326 * @param act_sel - Sensor Activation Mode Selection.
340 * @param dev - The device structure.
341 * @param clk_src - Clock source.
354 * @param dev - The device structure.
355 * @param cur_drv - Current Sensor Drive.
367 * Enable/disable the INTB-Pin interrupt assertion.
368 * @param dev - The device structure.
369 * @param enable - True = enable int assertion, false = disable int assertion.
382 * @param dev - The device structure.
383 * @param op_mode - Operation mode
397 * @param dev - The device structure.
398 * @param status - Data stored in the STATUS register
408 * @param dev - The device structure.
426 * @param dev - The device structure.
442 struct fdc2x1x_data *data = dev->data; in fdc2x1x_restart()
445 data->int_config, data->int_config); in fdc2x1x_restart()
457 * @param dev - The device structure.
458 * @param enable - True = enable shutdown, false = disable shutdown
463 const struct fdc2x1x_config *cfg = dev->config; in fdc2x1x_set_shutdown()
466 gpio_pin_set_dt(&cfg->sd_gpio, enable); in fdc2x1x_set_shutdown()
477 * @param dev - The device structure.
478 * @param pm_state - power management state
485 const struct fdc2x1x_config *cfg = dev->config; in fdc2x1x_device_pm_action()
519 if (cfg->sd_gpio.port->name) { in fdc2x1x_device_pm_action()
523 ret = -ENOTSUP; in fdc2x1x_device_pm_action()
527 return -ENOTSUP; in fdc2x1x_device_pm_action()
536 * @param dev - The device structure.
537 * @param chan - The sensor channel type.
538 * @param attr - The sensor attribute.
539 * @param value - The sensor attribute value.
547 return -ENOTSUP; in fdc2x1x_attr_set()
552 * @param dev - The device structure.
553 * @param cap_data - The sensor value data.
561 const struct fdc2x1x_config *cfg = dev->config; in fdc2x1x_get_cap_data()
562 struct fdc2x1x_data *data = dev->data; in fdc2x1x_get_cap_data()
564 uint8_t buf_size = cfg->num_channels; in fdc2x1x_get_cap_data()
566 if (data->fdc221x) { in fdc2x1x_get_cap_data()
586 return -EIO; in fdc2x1x_get_cap_data()
591 for (i = 0; i < cfg->num_channels; i++) { in fdc2x1x_get_cap_data()
592 if (data->fdc221x) { in fdc2x1x_get_cap_data()
593 data->channel_buf[i] = buf[i * 2] << 16 | buf[i * 2 + 1]; in fdc2x1x_get_cap_data()
595 data->channel_buf[i] = buf[i]; in fdc2x1x_get_cap_data()
604 * @param dev - The device structure.
605 * @param chan - The sensor channel type.
617 return -ENXIO; in fdc2x1x_sample_fetch()
626 * @param dev - The device structure.
627 * @param chan - The sensor channel type.
628 * @param val - The sensor channel value.
635 const struct fdc2x1x_config *cfg = dev->config; in fdc2x1x_channel_get()
641 val->val1 = (uint32_t)ch_data; in fdc2x1x_channel_get()
642 val->val2 = ((uint32_t)(ch_data * 1000000)) % 1000000; in fdc2x1x_channel_get()
645 if (cfg->num_channels >= 2) { in fdc2x1x_channel_get()
647 val->val1 = (uint32_t)ch_data; in fdc2x1x_channel_get()
648 val->val2 = ((uint32_t)(ch_data * 1000000)) % 1000000; in fdc2x1x_channel_get()
651 return -ENOTSUP; in fdc2x1x_channel_get()
655 if (cfg->num_channels >= 3) { in fdc2x1x_channel_get()
657 val->val1 = (uint32_t)ch_data; in fdc2x1x_channel_get()
658 val->val2 = ((uint32_t)(ch_data * 1000000)) % 1000000; in fdc2x1x_channel_get()
661 return -ENOTSUP; in fdc2x1x_channel_get()
665 if (cfg->num_channels == 4) { in fdc2x1x_channel_get()
667 val->val1 = (uint32_t)ch_data; in fdc2x1x_channel_get()
668 val->val2 = ((uint32_t)(ch_data * 1000000)) % 1000000; in fdc2x1x_channel_get()
671 return -ENOTSUP; in fdc2x1x_channel_get()
677 val->val1 = (uint32_t)ch_data; in fdc2x1x_channel_get()
678 val->val2 = ((uint32_t)(ch_data * 1000000)) % 1000000; in fdc2x1x_channel_get()
681 if (cfg->num_channels >= 2) { in fdc2x1x_channel_get()
684 val->val1 = (uint32_t)ch_data; in fdc2x1x_channel_get()
685 val->val2 = ((uint32_t)(ch_data * 1000000)) % 1000000; in fdc2x1x_channel_get()
688 return -ENOTSUP; in fdc2x1x_channel_get()
692 if (cfg->num_channels >= 3) { in fdc2x1x_channel_get()
695 val->val1 = (uint32_t)ch_data; in fdc2x1x_channel_get()
696 val->val2 = ((uint32_t)(ch_data * 1000000)) % 1000000; in fdc2x1x_channel_get()
699 return -ENOTSUP; in fdc2x1x_channel_get()
703 if (cfg->num_channels >= 4) { in fdc2x1x_channel_get()
706 val->val1 = (uint32_t)ch_data; in fdc2x1x_channel_get()
707 val->val2 = ((uint32_t)(ch_data * 1000000)) % 1000000; in fdc2x1x_channel_get()
710 return -ENOTSUP; in fdc2x1x_channel_get()
715 return -ENOTSUP; in fdc2x1x_channel_get()
734 const struct fdc2x1x_config *cfg = dev->config; in fdc2x1x_init_config()
735 struct fdc2x1x_data *data = dev->data; in fdc2x1x_init_config()
738 for (ch = 0; ch < cfg->num_channels; ch++) { in fdc2x1x_init_config()
739 ret = fdc2x1x_set_fin_sel(dev, ch, cfg->ch_cfg[ch].fin_sel); in fdc2x1x_init_config()
745 cfg->ch_cfg[ch].fref_divider); in fdc2x1x_init_config()
750 ret = fdc2x1x_set_idrive(dev, ch, cfg->ch_cfg[ch].idrive); in fdc2x1x_init_config()
756 cfg->ch_cfg[ch].settle_count); in fdc2x1x_init_config()
761 ret = fdc2x1x_set_rcount(dev, ch, cfg->ch_cfg[ch].rcount); in fdc2x1x_init_config()
766 if (!data->fdc221x) { in fdc2x1x_init_config()
768 cfg->ch_cfg[ch].offset); in fdc2x1x_init_config()
775 ret = fdc2x1x_set_autoscan_mode(dev, cfg->autoscan_en); in fdc2x1x_init_config()
780 ret = fdc2x1x_set_rr_sequence(dev, cfg->rr_sequence); in fdc2x1x_init_config()
785 ret = fdc2x1x_set_deglitch(dev, cfg->deglitch); in fdc2x1x_init_config()
790 if (!data->fdc221x) { in fdc2x1x_init_config()
791 ret = fdc2x1x_set_output_gain(dev, cfg->output_gain); in fdc2x1x_init_config()
797 ret = fdc2x1x_set_active_channel(dev, cfg->active_channel); in fdc2x1x_init_config()
802 ret = fdc2x1x_set_sensor_activate_sel(dev, cfg->sensor_activate_sel); in fdc2x1x_init_config()
807 ret = fdc2x1x_set_ref_clk_src(dev, cfg->clk_src); in fdc2x1x_init_config()
828 ret = fdc2x1x_set_current_drv(dev, cfg->current_drv); in fdc2x1x_init_config()
838 * @param dev - The device structure.
843 struct fdc2x1x_data *data = dev->data; in fdc2x1x_probe()
848 return -EIO; in fdc2x1x_probe()
853 data->fdc221x = true; in fdc2x1x_probe()
855 data->fdc221x = false; in fdc2x1x_probe()
858 return -ENODEV; in fdc2x1x_probe()
861 if (data->fdc221x) { in fdc2x1x_probe()
869 return -EIO; in fdc2x1x_probe()
874 return -ENODEV; in fdc2x1x_probe()
881 * Initialize the SD-Pin.
882 * @param dev - The device structure.
887 const struct fdc2x1x_config *cfg = dev->config; in fdc2x1x_init_sd_pin()
889 if (!gpio_is_ready_dt(&cfg->sd_gpio)) { in fdc2x1x_init_sd_pin()
890 LOG_ERR("%s: sd_gpio device not ready", cfg->sd_gpio.port->name); in fdc2x1x_init_sd_pin()
891 return -ENODEV; in fdc2x1x_init_sd_pin()
894 gpio_pin_configure_dt(&cfg->sd_gpio, GPIO_OUTPUT_INACTIVE); in fdc2x1x_init_sd_pin()
901 * @param dev - The device structure.
906 const struct fdc2x1x_config *cfg = dev->config; in fdc2x1x_init()
909 if (cfg->fdc2x14) { in fdc2x1x_init()
915 if (cfg->num_channels == 0) { in fdc2x1x_init()
917 return -EINVAL; in fdc2x1x_init()
918 } else if (cfg->num_channels > ch_supported) { in fdc2x1x_init()
920 return -EINVAL; in fdc2x1x_init()
923 if (cfg->sd_gpio.port->name) { in fdc2x1x_init()
925 return -ENODEV; in fdc2x1x_init()
929 if (!device_is_ready(cfg->i2c.bus)) { in fdc2x1x_init()
931 return -ENODEV; in fdc2x1x_init()
935 return -ENODEV; in fdc2x1x_init()
939 return -EIO; in fdc2x1x_init()
943 return -EIO; in fdc2x1x_init()
947 return -EIO; in fdc2x1x_init()
953 return -EIO; in fdc2x1x_init()