陈曦 9 months ago
commit bb30deca26

@ -36,6 +36,7 @@ add_definitions(-DUSING_NRSEC_VPN)
# OUTPUT_CAMERA_DBG_INFO: CARERA # OUTPUT_CAMERA_DBG_INFO: CARERA
# add_definitions(-DOUTPUT_CAMERA_DBG_INFO) # add_definitions(-DOUTPUT_CAMERA_DBG_INFO)
add_definitions(-DALIGN_HB_TIMER_TO_PHOTO) add_definitions(-DALIGN_HB_TIMER_TO_PHOTO)
add_definitions(-DENABLE_3V3_ALWAYS)
#add_definitions(-DUSING_N938) #add_definitions(-DUSING_N938)

@ -158,7 +158,7 @@ bool GpioControl::SetN938Cmd(int cmd, int val)
bool GpioControl::OpenSensors() 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); GpioControl::setInt(CMD_SET_485_EN_STATE, true ? 1 : 0);
int igpio; int igpio;
GpioControl::setInt(CMD_SET_WTH_POWER, 1); GpioControl::setInt(CMD_SET_WTH_POWER, 1);

@ -6,6 +6,8 @@
#define MICROPHOTO_GPIOCONTROL_H #define MICROPHOTO_GPIOCONTROL_H
#include <string> #include <string>
#include <chrono>
#include <thread>
#define CMD_GET_LIGHT_ADC 101 #define CMD_GET_LIGHT_ADC 101
#define CMD_SET_LIGHT_ADC 102 #define CMD_SET_LIGHT_ADC 102
@ -141,7 +143,11 @@ public:
static void setCam3V3Enable(bool enabled) 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); setInt(CMD_SET_CAM_3V3_EN_STATE, enabled ? 1 : 0);
#endif
} }
static void reboot() static void reboot()
@ -231,6 +237,10 @@ public:
static void setSpiPower(bool on) { static void setSpiPower(bool on) {
setInt(CMD_SET_SPI_POWER, on ? 1 : 0); setInt(CMD_SET_SPI_POWER, on ? 1 : 0);
if (on)
{
std::this_thread::sleep_for(std::chrono::milliseconds(40));
}
} }
static void setRS485Enable(bool z) { static void setRS485Enable(bool z) {

@ -818,6 +818,7 @@ Java_com_xypower_mpapp_MicroPhotoService_importPublicKeyFile(
const char *md5Str = env->GetStringUTFChars(md5, 0); const char *md5Str = env->GetStringUTFChars(md5, 0);
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL); CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true); GpioControl::setSpiPower(true);
@ -853,6 +854,7 @@ Java_com_xypower_mpapp_MicroPhotoService_importPublicKey(
return JNI_FALSE; return JNI_FALSE;
} }
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL); CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true); GpioControl::setSpiPower(true);
@ -889,7 +891,7 @@ Java_com_xypower_mpapp_MicroPhotoService_importPrivateKey(
return JNI_FALSE; return JNI_FALSE;
} }
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL); CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true); GpioControl::setSpiPower(true);
@ -927,6 +929,8 @@ Java_com_xypower_mpapp_MicroPhotoService_genKeys(
jclass cls, jint index) { jclass cls, jint index) {
#ifdef USING_NRSEC #ifdef USING_NRSEC
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL); CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true); GpioControl::setSpiPower(true);
@ -956,6 +960,7 @@ Java_com_xypower_mpapp_MicroPhotoService_querySecVersion(
std::string version; std::string version;
#ifdef USING_NRSEC #ifdef USING_NRSEC
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL); CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true); GpioControl::setSpiPower(true);
@ -986,6 +991,7 @@ Java_com_xypower_mpapp_MicroPhotoService_genCertRequest(
} }
const char *path = NRSEC_PATH; const char *path = NRSEC_PATH;
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL); CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true); GpioControl::setSpiPower(true);
@ -1043,6 +1049,7 @@ Java_com_xypower_mpapp_MicroPhotoService_importPrivateKeyFile(
const char *path = NRSEC_PATH; const char *path = NRSEC_PATH;
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL); CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true); GpioControl::setSpiPower(true);
@ -1082,6 +1089,7 @@ Java_com_xypower_mpapp_MicroPhotoService_exportPublicKeyFile(
uint8_t len = 0; uint8_t len = 0;
std::vector<unsigned char> data(64, 0); std::vector<unsigned char> data(64, 0);
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL); CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true); GpioControl::setSpiPower(true);
@ -1121,6 +1129,7 @@ Java_com_xypower_mpapp_MicroPhotoService_exportPrivateFile(
const char *path = NRSEC_PATH; const char *path = NRSEC_PATH;
GpioControl::setSpiPower(false);
CPhoneDevice::TurnOnCameraPower(NULL); CPhoneDevice::TurnOnCameraPower(NULL);
GpioControl::setSpiPower(true); GpioControl::setSpiPower(true);

@ -1322,7 +1322,6 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
} }
#endif #endif
// GpioControl::EnableGpio(CMD_SET_CAM_3V3_EN_STATE, true);
bool res = false; bool res = false;
if (photoInfo.usbCamera) if (photoInfo.usbCamera)

@ -213,8 +213,8 @@ public:
virtual int GetWData(WEATHER_INFO *weatherInfo); virtual int GetWData(WEATHER_INFO *weatherInfo);
virtual int GetIceData(ICE_INFO *iceInfo, ICE_TAIL *icetail, SENSOR_PARAM *sensorParam); virtual int GetIceData(ICE_INFO *iceInfo, ICE_TAIL *icetail, SENSOR_PARAM *sensorParam);
virtual bool OpenSensors(); virtual bool OpenSensors();
virtual bool CloseSensors(); virtual bool CloseSensors();
bool GetNextScheduleItem(uint32_t tsBasedZero, uint32_t scheduleTime, vector<uint32_t>& items); bool GetNextScheduleItem(uint32_t tsBasedZero, uint32_t scheduleTime, vector<uint32_t>& items);

@ -86,7 +86,11 @@ static void set12VEnable(bool z) {
static void setCam3V3Enable(bool enabled) 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); setInt(CMD_SET_CAM_3V3_EN_STATE, enabled ? 1 : 0);
#endif
} }
#if 0 #if 0

@ -142,11 +142,6 @@ static void set12VEnable(bool z) {
setInt(CMD_SET_12V_EN_STATE, z ? 1 : 0); setInt(CMD_SET_12V_EN_STATE, z ? 1 : 0);
} }
static void setCam3V3Enable(bool enabled)
{
setInt(CMD_SET_CAM_3V3_EN_STATE, enabled ? 1 : 0);
}
/********************************************************************************* /*********************************************************************************
* * * *

Loading…
Cancel
Save