From 92f61a3a4f03ecf91e987b90c2a00b469a0e11bb Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 16 Aug 2024 15:48:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0N938=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E4=BC=A0=E6=84=9F=E5=99=A8=E6=89=93=E5=BC=80=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 需调整 --- app/src/main/cpp/GPIOControl.cpp | 60 ++++++++++++++++++++++++++++++++ app/src/main/cpp/GPIOControl.h | 13 +++++-- 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/GPIOControl.cpp b/app/src/main/cpp/GPIOControl.cpp index 670e1617..5ba801bc 100644 --- a/app/src/main/cpp/GPIOControl.cpp +++ b/app/src/main/cpp/GPIOControl.cpp @@ -131,3 +131,63 @@ std::string GpioControl::getString(int cmd) } return ""; } + +#ifdef USING_N938 + +bool GpioControl::SetN938Cmd(int cmd, int val) +{ + char buf[32] = { 0 }; + snprintf(buf, "out %d %d", cmd, val); + + IOT_PARAM param; + int len = MAX_STRING_LEN < strlen(buf) ? MAX_STRING_LEN : strlen(buf); + + param.cmd = cmd; + memset(param.str, 0, MAX_STRING_LEN); + memcpy(param.str, value.c_str(), len); + + int fd = open(GPIO_NODE_MP, O_RDONLY); + if( fd > 0 ) + { + ioctl(fd, IOT_PARAM_WRITE, ¶m); + close(fd); + } + return; +} + +bool GpioControl::OpenSensors() +{ + + GpioControl::setInt(CMD_SET_CAM_3V3_EN_STATE, true ? 1 : 0); + GpioControl::setInt(CMD_SET_485_EN_STATE, true ? 1 : 0); + int igpio; + GpioControl::setInt(CMD_SET_WTH_POWER, 1); + GpioControl::setInt(CMD_SET_PULL_POWER, 1); + GpioControl::setInt(CMD_SET_ANGLE_POWER, 1); + GpioControl::setInt(CMD_SET_OTHER_POWER, 1); + GpioControl::setInt(CMD_SET_PIC1_POWER, 1); + + igpio = GpioControl::getInt(CMD_SET_WTH_POWER); + igpio = GpioControl::getInt(CMD_SET_PULL_POWER); + igpio = GpioControl::getInt(CMD_SET_ANGLE_POWER); + igpio = GpioControl::getInt(CMD_SET_OTHER_POWER); + igpio = GpioControl::getInt(CMD_SET_PIC1_POWER); + + GpioControl::setInt(CMD_SET_SPI_POWER, 1); + GpioControl::setInt(CMD_SET_485_en0, 1); + GpioControl::setInt(CMD_SET_485_en1, 1); + GpioControl::setInt(CMD_SET_485_en2, 1); + GpioControl::setInt(CMD_SET_485_en3, 1); + GpioControl::setInt(CMD_SET_485_en4, 1); + + igpio = GpioControl::getInt(CMD_SET_SPI_POWER); + igpio = GpioControl::getInt(CMD_SET_485_en0); + igpio = GpioControl::getInt(CMD_SET_485_en1); + igpio = GpioControl::getInt(CMD_SET_485_en2); + igpio = GpioControl::getInt(CMD_SET_485_en3); + igpio = GpioControl::getInt(CMD_SET_485_en4); + return 0; + +} + +#endif diff --git a/app/src/main/cpp/GPIOControl.h b/app/src/main/cpp/GPIOControl.h index ef239c29..dad4dce4 100644 --- a/app/src/main/cpp/GPIOControl.h +++ b/app/src/main/cpp/GPIOControl.h @@ -40,6 +40,7 @@ #ifdef USING_N938 + #define CMD_SET_WTH_POWER 490 #define CMD_SET_PULL_POWER 491 #define CMD_SET_ANGLE_POWER 492 @@ -52,17 +53,19 @@ #define CMD_SET_485_en4 305 + + #define CMD_485_0_DE 156 // 485_0 DE信号 #define CMD_485_0_PWR_EN 157 // 485_0 电源使能 #define CMD_485_0_1_DE_EN 171 // 485_0&1DE电平转换芯片使能信号 #define CMD_485_1_DE 172 // - #define CMD_SET_CAM_3V3_EN_STATE 72 // 整板3V3上电使能 #define CMD_3V3_SWITCH_EN 45 // 整板485_3V3信号电平转换电源使能 #define CMD_UART0_EN 73 // 预留UART0电平转换芯片使能 #define CMD_485_1_PWR_EN 5 // 485_1 电源使能 + #define CMD_485_3_DE 6 // 485_3 DE信号 #define CMD_485_2_DE 7 // 485_2 DE信号 #define CMD_485_4_DE 13 // 485_4 DE信号 @@ -77,9 +80,7 @@ #define CMD_485_2_3_DE_EN 26 // 485_2&3 DE电平转换芯片使能信号 #define CMD_5V_PWR_EN 14 // 整板5V0上电使能 - #define CMD_SD_CARD_DECT 15 // SD CARD DECT - #define CMD_PIC1_EN 16 #define CMD_OTHER_EN 21 @@ -227,6 +228,12 @@ public: setInt(CMD_SET_12V_EN_STATE, z ? 1 : 0); } +#ifdef USING_N938 + static bool SetN938Cmd(int cmd, int val); + static bool OpenSensors(); + static bool CloseSensors(); +#endif + };