drivers: sensors: sbs-gauge: add CHAN_ALL to fetch

Add the SENSORS_CHAN_ALL to the fetch function.

Signed-off-by: Alexander Wachter <alexander.wachter@leica-geosystems.com>
This commit is contained in:
Alexander Wachter 2021-05-19 11:37:43 +02:00 committed by Kumar Gala
commit 1c792fb0b5

View file

@ -108,6 +108,20 @@ static int sbs_gauge_channel_get(const struct device *dev,
return 0; return 0;
} }
static const uint16_t all_channels[] = {
SENSOR_CHAN_GAUGE_VOLTAGE,
SENSOR_CHAN_GAUGE_AVG_CURRENT,
SENSOR_CHAN_GAUGE_TEMP,
SENSOR_CHAN_GAUGE_STATE_OF_CHARGE,
SENSOR_CHAN_GAUGE_FULL_CHARGE_CAPACITY,
SENSOR_CHAN_GAUGE_REMAINING_CHARGE_CAPACITY,
SENSOR_CHAN_GAUGE_NOM_AVAIL_CAPACITY,
SENSOR_CHAN_GAUGE_FULL_AVAIL_CAPACITY,
SENSOR_CHAN_GAUGE_TIME_TO_EMPTY,
SENSOR_CHAN_GAUGE_TIME_TO_FULL,
SENSOR_CHAN_GAUGE_CYCLE_COUNT
};
static int sbs_gauge_sample_fetch(const struct device *dev, static int sbs_gauge_sample_fetch(const struct device *dev,
enum sensor_channel chan) enum sensor_channel chan)
{ {
@ -222,6 +236,16 @@ static int sbs_gauge_sample_fetch(const struct device *dev,
} }
break; break;
case SENSOR_CHAN_ALL:
for (int i = 0; i < ARRAY_SIZE(all_channels); i++) {
status = sbs_gauge_sample_fetch(dev, all_channels[i]);
if (status != 0) {
break;
}
}
break;
default: default:
return -ENOTSUP; return -ENOTSUP;
} }