From 1ac95cada31937766a01f0f67152a2f23c4a92bb Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 6 Sep 2024 15:55:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=B5=E6=BA=90=E6=8E=A7?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/CMakeLists.txt | 1 + app/src/main/cpp/GPIOControl.cpp | 2 +- app/src/main/cpp/GPIOControl.h | 10 ++++++++++ app/src/main/cpp/MicroPhoto.cpp | 11 ++++++++++- app/src/main/cpp/PhoneDevice.cpp | 1 - app/src/main/cpp/SensorsProtocol.cpp | 4 ++++ app/src/main/cpp/serial/WeatherComm.cpp | 5 ----- 7 files changed, 26 insertions(+), 8 deletions(-) diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 88d1446e..d71359f3 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -36,6 +36,7 @@ add_definitions(-DUSING_NRSEC_VPN) # OUTPUT_CAMERA_DBG_INFO: 照片上打印CARERA相关信息 # add_definitions(-DOUTPUT_CAMERA_DBG_INFO) add_definitions(-DALIGN_HB_TIMER_TO_PHOTO) +add_definitions(-DENABLE_3V3_ALWAYS) # add_definitions(-DUSING_N938) diff --git a/app/src/main/cpp/GPIOControl.cpp b/app/src/main/cpp/GPIOControl.cpp index 5ba801bc..d4b69f39 100644 --- a/app/src/main/cpp/GPIOControl.cpp +++ b/app/src/main/cpp/GPIOControl.cpp @@ -158,7 +158,7 @@ bool GpioControl::SetN938Cmd(int cmd, int val) bool GpioControl::OpenSensors() { - GpioControl::setInt(CMD_SET_CAM_3V3_EN_STATE, true ? 1 : 0); + GpioControl::setCam3V3Enable(true); GpioControl::setInt(CMD_SET_485_EN_STATE, true ? 1 : 0); int igpio; GpioControl::setInt(CMD_SET_WTH_POWER, 1); diff --git a/app/src/main/cpp/GPIOControl.h b/app/src/main/cpp/GPIOControl.h index ba976153..96f73e04 100644 --- a/app/src/main/cpp/GPIOControl.h +++ b/app/src/main/cpp/GPIOControl.h @@ -6,6 +6,8 @@ #define MICROPHOTO_GPIOCONTROL_H #include +#include +#include #define CMD_GET_LIGHT_ADC 101 #define CMD_SET_LIGHT_ADC 102 @@ -141,7 +143,11 @@ public: static void setCam3V3Enable(bool enabled) { +#ifdef ENABLE_3V3_ALWAYS + setInt(CMD_SET_CAM_3V3_EN_STATE, 1); +#else setInt(CMD_SET_CAM_3V3_EN_STATE, enabled ? 1 : 0); +#endif } static void reboot() @@ -231,6 +237,10 @@ public: static void setSpiPower(bool on) { setInt(CMD_SET_SPI_POWER, on ? 1 : 0); + if (on) + { + std::this_thread::sleep_for(std::chrono::milliseconds(40)); + } } static void setRS485Enable(bool z) { diff --git a/app/src/main/cpp/MicroPhoto.cpp b/app/src/main/cpp/MicroPhoto.cpp index 2fd4c4df..f2d42bbc 100644 --- a/app/src/main/cpp/MicroPhoto.cpp +++ b/app/src/main/cpp/MicroPhoto.cpp @@ -818,6 +818,7 @@ Java_com_xypower_mpapp_MicroPhotoService_importPublicKeyFile( const char *md5Str = env->GetStringUTFChars(md5, 0); + GpioControl::setSpiPower(false); CPhoneDevice::TurnOnCameraPower(NULL); GpioControl::setSpiPower(true); @@ -853,6 +854,7 @@ Java_com_xypower_mpapp_MicroPhotoService_importPublicKey( return JNI_FALSE; } + GpioControl::setSpiPower(false); CPhoneDevice::TurnOnCameraPower(NULL); GpioControl::setSpiPower(true); @@ -889,7 +891,7 @@ Java_com_xypower_mpapp_MicroPhotoService_importPrivateKey( return JNI_FALSE; } - + GpioControl::setSpiPower(false); CPhoneDevice::TurnOnCameraPower(NULL); GpioControl::setSpiPower(true); @@ -927,6 +929,8 @@ Java_com_xypower_mpapp_MicroPhotoService_genKeys( jclass cls, jint index) { #ifdef USING_NRSEC + + GpioControl::setSpiPower(false); CPhoneDevice::TurnOnCameraPower(NULL); GpioControl::setSpiPower(true); @@ -956,6 +960,7 @@ Java_com_xypower_mpapp_MicroPhotoService_querySecVersion( std::string version; #ifdef USING_NRSEC + GpioControl::setSpiPower(false); CPhoneDevice::TurnOnCameraPower(NULL); GpioControl::setSpiPower(true); @@ -986,6 +991,7 @@ Java_com_xypower_mpapp_MicroPhotoService_genCertRequest( } const char *path = NRSEC_PATH; + GpioControl::setSpiPower(false); CPhoneDevice::TurnOnCameraPower(NULL); GpioControl::setSpiPower(true); @@ -1043,6 +1049,7 @@ Java_com_xypower_mpapp_MicroPhotoService_importPrivateKeyFile( const char *path = NRSEC_PATH; + GpioControl::setSpiPower(false); CPhoneDevice::TurnOnCameraPower(NULL); GpioControl::setSpiPower(true); @@ -1082,6 +1089,7 @@ Java_com_xypower_mpapp_MicroPhotoService_exportPublicKeyFile( uint8_t len = 0; std::vector data(64, 0); + GpioControl::setSpiPower(false); CPhoneDevice::TurnOnCameraPower(NULL); GpioControl::setSpiPower(true); @@ -1121,6 +1129,7 @@ Java_com_xypower_mpapp_MicroPhotoService_exportPrivateFile( const char *path = NRSEC_PATH; + GpioControl::setSpiPower(false); CPhoneDevice::TurnOnCameraPower(NULL); GpioControl::setSpiPower(true); diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index d417b18a..0639a82f 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -1322,7 +1322,6 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector< } #endif - // GpioControl::EnableGpio(CMD_SET_CAM_3V3_EN_STATE, true); bool res = false; if (photoInfo.usbCamera) diff --git a/app/src/main/cpp/SensorsProtocol.cpp b/app/src/main/cpp/SensorsProtocol.cpp index d3f90c22..12d6ffa0 100644 --- a/app/src/main/cpp/SensorsProtocol.cpp +++ b/app/src/main/cpp/SensorsProtocol.cpp @@ -86,7 +86,11 @@ static void set12VEnable(bool z) { static void setCam3V3Enable(bool enabled) { +#ifdef ENABLE_3V3_ALWAYS + setInt(CMD_SET_CAM_3V3_EN_STATE, 1); +#else setInt(CMD_SET_CAM_3V3_EN_STATE, enabled ? 1 : 0); +#endif } #if 0 diff --git a/app/src/main/cpp/serial/WeatherComm.cpp b/app/src/main/cpp/serial/WeatherComm.cpp index 01da9869..dabd6b61 100644 --- a/app/src/main/cpp/serial/WeatherComm.cpp +++ b/app/src/main/cpp/serial/WeatherComm.cpp @@ -142,11 +142,6 @@ static void set12VEnable(bool z) { setInt(CMD_SET_12V_EN_STATE, z ? 1 : 0); } -static void setCam3V3Enable(bool enabled) -{ - setInt(CMD_SET_CAM_3V3_EN_STATE, enabled ? 1 : 0); -} - /********************************************************************************* * 气象数据处理 *