Set NMI_OUT according to the configuration file
Configuration file supports setting the polarity of the nmi_out pin so
we don't have to hardcode the polarity
Tested:
On a machine, without this change, nmi_out always triggers and causes
the host to crash
With this change, the host no longer crashes after the polarity of the
nmi out pin is configured correctly
Change-Id: I34049136c0ede117eec50b5ce47698f1b319624c
Signed-off-by: John Wang <wangzhiqiang02@inspur.com>
diff --git a/src/power_control.cpp b/src/power_control.cpp
index f93a1fc..563b008 100644
--- a/src/power_control.cpp
+++ b/src/power_control.cpp
@@ -2070,17 +2070,16 @@
static void nmiReset(void)
{
- static constexpr const uint8_t value = 1;
const static constexpr int nmiOutPulseTimeMs = 200;
lg2::info("NMI out action");
- nmiOutLine.set_value(value);
+ nmiOutLine.set_value(!nmiOutConfig.polarity);
lg2::info("{GPIO_NAME} set to {GPIO_VALUE}", "GPIO_NAME",
- nmiOutConfig.lineName, "GPIO_VALUE", value);
+ 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(!value);
+ nmiOutLine.set_value(nmiOutConfig.polarity);
lg2::info("{GPIO_NAME} released", "GPIO_NAME", nmiOutConfig.lineName);
if (ec)
{
@@ -2717,7 +2716,7 @@
// initialize NMI_OUT GPIO.
if (!nmiOutConfig.lineName.empty())
{
- setGPIOOutput(nmiOutConfig.lineName, 0, nmiOutLine);
+ setGPIOOutput(nmiOutConfig.lineName, nmiOutConfig.polarity, nmiOutLine);
}
// Initialize POWER_OUT and RESET_OUT GPIO.