phosphor-buttons: Make gpio interrupt configuration can be set correctly

Test-By: Nuvoton NPCM750 EVB with external buttons to control power on and reset host server.

Signed-off-by: Tim Lee <timlee660101@gmail.com>
Change-Id: I17190121ff3cc6821557adaf128b1a8819848073
diff --git a/src/gpio.cpp b/src/gpio.cpp
index a398d04..05b8e15 100644
--- a/src/gpio.cpp
+++ b/src/gpio.cpp
@@ -247,6 +247,24 @@
     }
     else if ((gpioDirection == "both"))
     {
+        // Before set gpio configure as an interrupt pin, need to set direction
+        // as 'in' or edge can't set as 'rising', 'falling' and 'both'
+        const char* in_direction = "in";
+        devPath = gpioDev + "/gpio" + std::to_string(gpioNum) + "/direction";
+
+        stream.open(devPath, std::fstream::out);
+        try
+        {
+            stream << in_direction;
+            stream.close();
+        }
+
+        catch (const std::exception& e)
+        {
+            log<level::ERR>("Error in writing!");
+            return -1;
+        }
+        devPath.clear();
 
         // For gpio configured as ‘both’, it is an interrupt pin and trigged on
         // both rising and falling signals