From f28eeb31224bc4feded2e05e0c26e2ec7c53b392 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 10 Aug 2024 10:30:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/GPIOControl.cpp | 13 ++++++------- app/src/main/cpp/GPIOControl.h | 3 +++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/cpp/GPIOControl.cpp b/app/src/main/cpp/GPIOControl.cpp index 783025af..3bba8be7 100644 --- a/app/src/main/cpp/GPIOControl.cpp +++ b/app/src/main/cpp/GPIOControl.cpp @@ -43,7 +43,7 @@ typedef struct{ void GpioControl::setInt(int cmd, int value) { - int fd = open("/dev/mtkgpioctrl", O_RDONLY); + int fd = open(GPIO_NODE_MP, O_RDONLY); IOT_PARAM param; param.cmd = cmd; param.value = value; @@ -59,7 +59,7 @@ void GpioControl::setInt(int cmd, int value) int GpioControl::getInt(int cmd) { - int fd = open("/dev/mtkgpioctrl", O_RDONLY); + int fd = open(GPIO_NODE_MP, O_RDONLY); // LOGE("get_int fd=%d,cmd=%d\r\n",fd, cmd); if( fd > 0 ) { @@ -77,7 +77,7 @@ int GpioControl::getInt(int cmd) void GpioControl::setLong(int cmd, long value) { - int fd = open("/dev/mtkgpioctrl", O_RDONLY); + int fd = open(GPIO_NODE_MP, O_RDONLY); IOT_PARAM param; param.cmd = cmd; param.value2 = value; @@ -93,7 +93,7 @@ void GpioControl::setLong(int cmd, long value) long GpioControl::getLong(int cmd) { - int fd = open("/dev/mtkgpioctrl", O_RDONLY); + int fd = open(GPIO_NODE_MP, O_RDONLY); // LOGE("get_long fd=%d,cmd=%d\r\n",fd, cmd); if( fd > 0 ) { @@ -110,8 +110,7 @@ long GpioControl::getLong(int cmd) void GpioControl::setString(int cmd, const std::string& value) { IOT_PARAM param; - // char *pval = jstringToChars(env, value); - int fd = open("/dev/mtkgpioctrl", O_RDONLY); + int fd = open(GPIO_NODE_MP, O_RDONLY); int len = MAX_STRING_LEN < value.size() ? MAX_STRING_LEN : value.size(); param.cmd = cmd; @@ -129,7 +128,7 @@ void GpioControl::setString(int cmd, const std::string& value) std::string GpioControl::getString(int cmd) { - int fd = open("/dev/mtkgpioctrl", O_RDONLY); + int fd = open(GPIO_NODE_MP, O_RDONLY); // LOGE("get_string fd=%d,cmd=%d\r\n",fd, cmd); if( fd > 0 ) { diff --git a/app/src/main/cpp/GPIOControl.h b/app/src/main/cpp/GPIOControl.h index 70339636..e7090c20 100644 --- a/app/src/main/cpp/GPIOControl.h +++ b/app/src/main/cpp/GPIOControl.h @@ -48,6 +48,9 @@ #define CMD_SET_485_en4 305 +#define GPIO_NODE_MP "/dev/mtkgpioctrl" +#define GPIO_NODE_N938 "/sys/devices/platform/1000b000.pinctrl/mt_gpio" + class GpioControl { public: