drivers: sensor: zephyr_thermistor: align connection type with Linux
It looks like the Zephyr thermistor driver bindings were half-copied from Linux ntc-thermistor. Zephyr principle is to maintain compatibility with Linux, when possible, so there's no reason to deviate here. Convert the connection type from a custom enum to a boolean, as Linux does. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
4310853d07
commit
c60e4ec989
|
@ -52,7 +52,7 @@
|
|||
pullup-uv = <3300000>;
|
||||
pullup-ohm = <0>;
|
||||
pulldown-ohm = <10000>;
|
||||
connection-type = "NTC_CONNECTED_POSITIVE";
|
||||
connected-positive;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ static int zephyr_ntc_thermistor_init(const struct device *dev)
|
|||
.pullup_uv = DT_INST_PROP(inst, pullup_uv), \
|
||||
.pullup_ohm = DT_INST_PROP(inst, pullup_ohm), \
|
||||
.pulldown_ohm = DT_INST_PROP(inst, pulldown_ohm), \
|
||||
.connection_type = DT_INST_STRING_TOKEN(inst, connection_type), \
|
||||
.connected_positive = DT_INST_PROP(inst, connected_positive), \
|
||||
.type = &NTC_TYPE_NAME(DT_INST_PROP(inst, zephyr_rt_table)), \
|
||||
}, \
|
||||
}; \
|
||||
|
|
|
@ -14,11 +14,6 @@ struct ntc_compensation {
|
|||
const uint32_t ohm;
|
||||
};
|
||||
|
||||
enum ntc_type_e {
|
||||
NTC_CONNECTED_POSITIVE,
|
||||
NTC_CONNECTED_GROUND
|
||||
};
|
||||
|
||||
struct ntc_type {
|
||||
const struct ntc_compensation *comp;
|
||||
int n_comp;
|
||||
|
@ -26,7 +21,7 @@ struct ntc_type {
|
|||
};
|
||||
|
||||
struct ntc_config {
|
||||
enum ntc_type_e connection_type;
|
||||
bool connected_positive;
|
||||
uint32_t r25_ohm;
|
||||
uint32_t pullup_uv;
|
||||
uint32_t pullup_ohm;
|
||||
|
|
|
@ -104,7 +104,7 @@ uint32_t ntc_get_ohm_of_thermistor(const struct ntc_config *cfg, uint32_t max_ad
|
|||
{
|
||||
uint32_t ohm;
|
||||
|
||||
if (cfg->connection_type == NTC_CONNECTED_POSITIVE) {
|
||||
if (cfg->connected_positive) {
|
||||
ohm = cfg->pulldown_ohm * max_adc / (raw_adc - 1);
|
||||
} else {
|
||||
ohm = cfg->pullup_ohm * (raw_adc - 1) / max_adc;
|
||||
|
|
|
@ -38,10 +38,10 @@ properties:
|
|||
description: |
|
||||
The pulldown resistance in the circuit.
|
||||
|
||||
connection-type:
|
||||
type: string
|
||||
connected-positive:
|
||||
type: boolean
|
||||
description: |
|
||||
The connection type of the circuit model used.
|
||||
enum:
|
||||
- NTC_CONNECTED_POSITIVE
|
||||
- NTC_CONNECTED_GROUND
|
||||
Indicates how the thermistor is connected in series with a pull-up and/or
|
||||
a pull-down resistor. If this flag is NOT specified, the thermistor is
|
||||
assumed to be connected-ground, which usually means a pull-down resistance
|
||||
of zero but complex arrangements are possible.
|
||||
|
|
|
@ -53,5 +53,5 @@ test_adc_b57861s: b57861s@0 {
|
|||
pullup-uv = <3300000>;
|
||||
pullup-ohm = <0>;
|
||||
pulldown-ohm = <10000>;
|
||||
connection-type = "NTC_CONNECTED_POSITIVE";
|
||||
connected-positive;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue