diff options
author | Nick <nick.win999@gmail.com> | 2020-10-23 22:37:44 -0500 |
---|---|---|
committer | Nick <nick.win999@gmail.com> | 2020-10-23 22:37:44 -0500 |
commit | a67a8cd3b87e67176fb88c1d04d95004f7ff905d (patch) | |
tree | eaa8b573837c974331d32aaf9ba743ade2021523 /app/drivers/zephyr | |
parent | 6047415b1c26ec06198edecf656d6d9edcd01446 (diff) |
Check if fetch channel is supported
Diffstat (limited to 'app/drivers/zephyr')
-rw-r--r-- | app/drivers/zephyr/battery_voltage_divider.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/app/drivers/zephyr/battery_voltage_divider.c b/app/drivers/zephyr/battery_voltage_divider.c index 980f1b4..6139d46 100644 --- a/app/drivers/zephyr/battery_voltage_divider.c +++ b/app/drivers/zephyr/battery_voltage_divider.c @@ -58,6 +58,11 @@ static int bvd_sample_fetch(struct device *dev, enum sensor_channel chan) { const struct bvd_config *drv_cfg = dev->config_info; struct adc_sequence *as = &drv_data->as; + // Make sure selected channel is supported + if (chan != SENSOR_CHAN_GAUGE_VOLTAGE && chan != SENSOR_CHAN_GAUGE_STATE_OF_CHARGE) { + return -ENOTSUP; + } + int rc = 0; // Enable power GPIO if present |