[ADC-GPIO]Enabling ADC-Gpio Bridge
Commit 2: bridge
In case a channel has a bridge circuit,
we have to turn the bridge on prior to reading a value at least for one scan cycle
to get a valid value.
Add support for ADC channel controlled by GPIO.
For example,ADC channel8, connected to CMOS battery, is controlled by a GPIO.
Need set 1 to gpio when Channel8 sampling, and set 0 to gpio when finish sampling.
Another Commit 1:Enable ADC Gpio bridge configuration
Tested:
P3VBAT previous value is 0.4V
P3VBAT sensor reading now:3.0843V
Change-Id: I64325845dfd4a931d0beda28993f6b15fa31ae95
Signed-off-by: Zhu, Yunge <yunge.zhu@linux.intel.com>
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index 98b41a0..61ebd6c 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -23,6 +23,7 @@
#include <boost/algorithm/string/replace.hpp>
#include <boost/container/flat_set.hpp>
#include <fstream>
+#include <optional>
#include <regex>
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
@@ -212,10 +213,20 @@
setReadState(powerState, readState);
}
+ auto findBridgeGpio = baseConfiguration->second.find("BridgeGpio");
+ std::optional<int> gpioNum;
+
+ if (findBridgeGpio != baseConfiguration->second.end())
+ {
+ int gpioPin =
+ std::visit(VariantToIntVisitor(), findBridgeGpio->second);
+ gpioNum = static_cast<std::optional<int>>(gpioPin);
+ }
+
sensors[sensorName] = std::make_unique<ADCSensor>(
path.string(), objectServer, dbusConnection, io, sensorName,
- std::move(sensorThresholds), scaleFactor, readState,
- *interfacePath);
+ std::move(sensorThresholds), scaleFactor, readState, *interfacePath,
+ gpioNum);
}
}