NMI: Inverting the use of polarity
In idle state, the value of gpio should set to `!polarity`
(if ActiveHigh, the low should set into the gpioline), and in the
action, should use the polarity(not !polarity).
Change-Id: I20b37b71334f2ed4259421fc78a228da48bec8b5
Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com>
diff --git a/src/power_control.cpp b/src/power_control.cpp
index 7362c6c..9f5be28 100644
--- a/src/power_control.cpp
+++ b/src/power_control.cpp
@@ -2075,13 +2075,13 @@
const static constexpr int nmiOutPulseTimeMs = 200;
lg2::info("NMI out action");
- nmiOutLine.set_value(!nmiOutConfig.polarity);
+ nmiOutLine.set_value(nmiOutConfig.polarity);
lg2::info("{GPIO_NAME} set to {GPIO_VALUE}", "GPIO_NAME",
- nmiOutConfig.lineName, "GPIO_VALUE", !nmiOutConfig.polarity);
+ nmiOutConfig.lineName, "GPIO_VALUE", nmiOutConfig.polarity);
gpioAssertTimer.expires_after(std::chrono::milliseconds(nmiOutPulseTimeMs));
gpioAssertTimer.async_wait([](const boost::system::error_code ec) {
// restore the NMI_OUT GPIO line back to the opposite value
- nmiOutLine.set_value(nmiOutConfig.polarity);
+ nmiOutLine.set_value(!nmiOutConfig.polarity);
lg2::info("{GPIO_NAME} released", "GPIO_NAME", nmiOutConfig.lineName);
if (ec)
{
@@ -2718,7 +2718,8 @@
// initialize NMI_OUT GPIO.
if (!nmiOutConfig.lineName.empty())
{
- setGPIOOutput(nmiOutConfig.lineName, nmiOutConfig.polarity, nmiOutLine);
+ setGPIOOutput(nmiOutConfig.lineName, !nmiOutConfig.polarity,
+ nmiOutLine);
}
// Initialize POWER_OUT and RESET_OUT GPIO.