zephyr/tests/drivers/build_all
Gerard Marull-Paretas 44f48f6da7 drivers: sensor: zephyr_thermistor: refactor driver
Refactor driver to align a bit more with its Linux counterpart, ie,
ntc_thermistor. This driver did quite a few _unconventional_ things,
like using "zephyr," compatibles, a dedicated node for pre-computed
compensation table (referenced by the actual pseudo-device node), etc.
The comparison helper function should likely be simplified as well (to
avoid the need for custom wrapper for bsearch), but this can be done
later.

In this refactor, each thermistor gets a compatible, e.g. "epcos,xxxx".
Compatibles are known by the driver, so are compensation tables. This
simplifies devicetree files. There's no need to bother about
compensation tables in **every** board file if Zephyr supports a certain
NTC model.

In general we should respect Linux bindings, which in the end influence
how drivers are implemented. In this case, this principle resulted in
simplified, easier to use code.

For future developers, this is how support for a new NTC can be added:

1. Add to the end of the driver:

```c
 #undef DT_DRV_COMPAT
 #define DT_DRV_COMPAT vnd_model

 static __unused const struct ntc_compensation comp_vnd_model[] = {
     { x, y },
     ...,
 };

 #define DT_INST_FOREACH_STATUS_OKAY_VARGS(NTC_THERMISTOR_DEV_INIT,
                                           DT_DRV_COMPAT, comp_vnd_model)
```
3. In driver's Kconfig make sure it depends on
   DT_HAS_$DT_DRV_COMPAT$_ENABLED

Note: $X$ means _value_ of X.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-04 20:49:48 +02:00
..
adc tests: drivers: adc: add ADS114S08 2023-05-04 10:47:56 +02:00
can test: drivers: can: move build-only tests to proper location 2023-05-01 09:30:42 -05:00
counter samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
dac tests: build_all: add entries for ltc1660/ltc1665 2023-04-14 08:21:23 -04:00
eeprom samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
ethernet samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
fpga samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
gpio samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
i2c apps: misc void main -> int main fixes 2023-04-18 05:45:36 -07:00
i3c samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
ieee802154 samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
led samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
led_strip samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
mfd samples, tests: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
modem samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
pwm samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
rtc tests: drivers: build_all: rtc: api: add build-only test for PCF8523 2023-04-27 09:51:42 +02:00
sensor drivers: sensor: zephyr_thermistor: refactor driver 2023-05-04 20:49:48 +02:00
video samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00