Lines Matching +full:threshold +full:- +full:count

2  * Copyright (c) 2022 HAW Hamburg FTZ-DIWIP
4 * SPDX-License-Identifier: Apache-2.0
10 const struct max31865_config *cfg = dev->config; in max31865_spi_write()
18 const struct spi_buf_set tx = {.buffers = bufs, .count = 2}; in max31865_spi_write()
20 return spi_write_dt(&cfg->spi, &tx); in max31865_spi_write()
25 const struct max31865_config *cfg = dev->config; in max31865_spi_read()
29 const struct spi_buf_set tx = {.buffers = &tx_buf, .count = 1}; in max31865_spi_read()
35 const struct spi_buf_set rx = {.buffers = rx_buf, .count = 2}; in max31865_spi_read()
37 return spi_transceive_dt(&cfg->spi, &tx, &rx); in max31865_spi_read()
48 struct max31865_data *data = dev->data; in configure_device()
49 uint8_t cmd[] = {data->config_control_bits}; in configure_device()
59 * @brief Set device fail threshold registers
66 const struct max31865_config *config = dev->config; in set_threshold_values()
68 (config->high_threshold >> 7) & 0x00ff, (config->high_threshold << 1) & 0x00ff, in set_threshold_values()
69 (config->low_threshold >> 7) & 0x00ff, (config->low_threshold << 1) & 0x00ff}; in set_threshold_values()
81 * Apply the Callendar-Van Dusen equation to convert the RTD resistance
83 * Tr = (-A + SQRT(delta) ) / 2*B
84 * delta = A^2 - 4B*(1-Rt/Ro)
86 * https://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf
94 double delta = (RTD_A * RTD_A) - 4 * RTD_B * (1.0 - resistance / resistance_0); in calculate_temperature()
96 temperature = (-RTD_A + sqrt(delta)) / (2 * RTD_B); in calculate_temperature()
102 temperature = RTD_C[0] + RTD_C[1] * resistance + RTD_C[2] * pow(resistance, 2) - in calculate_temperature()
103 RTD_C[3] * pow(resistance, 3) - RTD_C[4] * pow(resistance, 4) + in calculate_temperature()
111 * Apply a very good linear approximation of the Callendar-Van Dusen equation to convert the RTD
121 temperature = (resistance - resistance_0) / (resistance_0 * RTD_A); in calculate_temperature()
136 struct max31865_data *data = dev->data; in max31865_set_vbias()
138 WRITE_BIT(data->config_control_bits, 7, enable); in max31865_set_vbias()
144 struct max31865_data *data = dev->data; in max31865_set_three_wire()
146 WRITE_BIT(data->config_control_bits, 4, enable); in max31865_set_three_wire()
160 return "RTDIN- < 0.85*VBIAS (FORCE- open)"; in max31865_error_to_string()
163 return "REFIN- < 0.85*VBIAS (FORCE- open)"; in max31865_error_to_string()
166 return "REFIN- > 0.85*VBIAS"; in max31865_error_to_string()
169 return "RTD below low threshold"; in max31865_error_to_string()
172 return "RTD above high threshold"; in max31865_error_to_string()
183 struct max31865_data *data = dev->data; in max31865_fault_register()
184 saved_fault_bits = data->config_control_bits & FAULT_BITS_CLEAR_MASK; in max31865_fault_register()
186 WRITE_BIT(data->config_control_bits, 1, 1); in max31865_fault_register()
187 data->config_control_bits &= ~FAULT_BITS_CLEAR_MASK; in max31865_fault_register()
191 WRITE_BIT(data->config_control_bits, 1, 0); in max31865_fault_register()
192 data->config_control_bits |= saved_fault_bits; in max31865_fault_register()
222 return -EIO; in max31865_get_temperature()
229 return -EIO; in max31865_get_temperature()
232 const struct max31865_config *config = dev->config; in max31865_get_temperature()
233 struct max31865_data *data = dev->data; in max31865_get_temperature()
239 resistance *= config->resistance_reference; in max31865_get_temperature()
240 data->temperature = calculate_temperature(resistance, config->resistance_at_zero); in max31865_get_temperature()
246 const struct max31865_config *config = dev->config; in max31865_init()
248 if (!spi_is_ready_dt(&config->spi)) { in max31865_init()
249 return -ENODEV; in max31865_init()
251 struct max31865_data *data = dev->data; in max31865_init()
253 data->config_control_bits = 0; in max31865_init()
255 WRITE_BIT(data->config_control_bits, 6, config->conversion_mode); in max31865_init()
256 WRITE_BIT(data->config_control_bits, 5, config->one_shot); in max31865_init()
257 data->config_control_bits |= config->fault_cycle & 0b00001100; in max31865_init()
258 WRITE_BIT(data->config_control_bits, 0, config->filter_50hz); in max31865_init()
263 max31865_set_three_wire(dev, config->three_wire); in max31865_init()
271 return -ENOTSUP; in max31865_sample_fetch()
279 struct max31865_data *data = dev->data; in max31865_channel_get()
283 return sensor_value_from_double(val, data->temperature); in max31865_channel_get()
285 return -ENOTSUP; in max31865_channel_get()
294 return -ENOTSUP; in max31865_attr_set()
299 return max31865_set_three_wire(dev, val->val1); in max31865_attr_set()
301 return -ENOTSUP; in max31865_attr_set()