drivers: sensor: ntc_thermistor: add support for generic NTC
Add support for a generic NTC, `ntc-thermistor-generic`. In this case, the compensation table is provided via devicetree. Note that DT property is prefixed with `zephyr,`, because while hardware related, it is linked to a particular software implementation. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
44f48f6da7
commit
84fd4e671f
4 changed files with 40 additions and 1 deletions
|
@ -5,7 +5,8 @@
|
|||
config NTC_THERMISTOR
|
||||
bool "NTC Thermistor"
|
||||
default y
|
||||
depends on DT_HAS_EPCOS_B57861S0103A039_ENABLED
|
||||
depends on DT_HAS_NTC_THERMISTOR_GENERIC_ENABLED || \
|
||||
DT_HAS_EPCOS_B57861S0103A039_ENABLED
|
||||
select ADC
|
||||
help
|
||||
Enable driver for Zephyr NTC Thermistor.
|
||||
|
|
|
@ -132,7 +132,17 @@ static int ntc_thermistor_init(const struct device *dev)
|
|||
&ntc_thermistor_cfg_##id##inst, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, \
|
||||
&ntc_thermistor_driver_api);
|
||||
|
||||
/* ntc-thermistor-generic */
|
||||
#define DT_DRV_COMPAT ntc_thermistor_generic
|
||||
|
||||
#define NTC_THERMISTOR_GENERIC_DEFINE(inst) \
|
||||
static const uint32_t comp_##inst[] = DT_INST_PROP(inst, zephyr_compensation_table); \
|
||||
NTC_THERMISTOR_DEFINE(inst, DT_DRV_COMPAT, comp_##inst)
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(NTC_THERMISTOR_GENERIC_DEFINE)
|
||||
|
||||
/* epcos,b57861s0103a039 */
|
||||
#undef DT_DRV_COMPAT
|
||||
#define DT_DRV_COMPAT epcos_b57861s0103a039
|
||||
|
||||
static __unused const struct ntc_compensation comp_epcos_b57861s0103a039[] = {
|
||||
|
|
17
dts/bindings/sensor/ntc-thermistor-generic.yaml
Normal file
17
dts/bindings/sensor/ntc-thermistor-generic.yaml
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Copyright (c) 2023 Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
description: Generic NTC thermistor
|
||||
|
||||
compatible: "ntc-thermistor-generic"
|
||||
|
||||
include: ntc-thermistor.yaml
|
||||
|
||||
properties:
|
||||
zephyr,compensation-table:
|
||||
type: array
|
||||
required: true
|
||||
description: |
|
||||
Compensation table, formatted as temperature, resistance pairs. A script
|
||||
to generate a valid table is provided in
|
||||
scripts/utils/ntc_thermistor_table.py.
|
|
@ -23,6 +23,17 @@ test_adc_emul: adc {
|
|||
status = "okay";
|
||||
};
|
||||
|
||||
test_ntc_thermistor_generic: ntc-thermistor-generic {
|
||||
compatible = "ntc-thermistor-generic";
|
||||
io-channels = <&adc0 0>;
|
||||
r25-ohm = <10000>;
|
||||
pullup-uv = <3300000>;
|
||||
pullup-ohm = <0>;
|
||||
pulldown-ohm = <10000>;
|
||||
connected-positive;
|
||||
zephyr,compensation-table = <0 0>, <1 1>;
|
||||
};
|
||||
|
||||
test_epcos_b57861s0103a039: epcos-b57861s0103a039 {
|
||||
compatible = "epcos,b57861s0103a039";
|
||||
io-channels = <&adc0 0>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue