调整938相关的GPIO控制

hdrplus
Matthew 7 months ago
parent 1f18a20b14
commit 7cd424953a

@ -38,11 +38,10 @@ std::vector<std::pair<int, uint32_t>> GpioControl::m_references;
void GpioControl::setInt(int cmd, int value)
{
int fd = -1;
IOT_PARAM param;
param.cmd = cmd;
param.value = value;
IOT_PARAM param = { cmd, value, 0 };
// param.cmd = cmd;
// param.value = value;
int res = 0;
// LOGE("set_int fd=%d,cmd=%d,value=%d\r\n",fd, cmd, value);
uint32_t references = (value != 0) ? 1 : 0;
std::vector<std::pair<int, uint32_t> >::iterator it;
@ -54,6 +53,9 @@ void GpioControl::setInt(int cmd, int value)
if( fd > 0 )
{
res = ioctl(fd, IOT_PARAM_WRITE, &param);
#ifdef _DEBUG
ALOGI("setInt cmd=%d,value=%d,result=%d\r\n",param.cmd, param.value, param.result);
#endif
close(fd);
// check res???
for (it = m_references.begin(); it != m_references.end(); ++it)
@ -93,6 +95,9 @@ void GpioControl::setInt(int cmd, int value)
fd = open(GPIO_NODE_MP, O_RDONLY);
if (fd > 0) {
res = ioctl(fd, IOT_PARAM_WRITE, &param);
#ifdef _DEBUG
ALOGI("setInt cmd=%d,value=%d,result=%d\r\n",param.cmd, param.value, param.result);
#endif
close(fd);
}
}

@ -12,6 +12,12 @@
#include <vector>
#include <utility>
#ifndef USING_N938
#ifndef USING_PLZ // MicroPhoto
#define CMD_GET_LIGHT_ADC 101
#define CMD_SET_LIGHT_ADC 102
#define CMD_GET_KEY_LOCKSTATE 103
@ -44,71 +50,48 @@
#define CMD_SET_CAM_3V3_EN_STATE 132
#endif
#else // defined(USING_PLZ)
#define CMD_SET_485_ENABLE 512
#define CMD_SET_3V3_PWR_ENABLE 516
#define CMD_SET_5V_PWR_ENABLE 517
#define CMD_SET_SENSOR_ENABLE 504
#define CMD_SET_SENSOR_PWR_ENABLE 505
#define CMD_SET_SENSOR2_ENABLE 506
#define CMD_SET_SENSOR4_ENABLE 510
#define CMD_SET_SENSOR1_PWR_ENABLE 513
#define CMD_SET_SENSOR2_PWR_ENABLE 514
#define CMD_SET_SENSOR3_PWR_ENABLE 509
#define CMD_SET_SENSOR4_PWR_ENABLE 525
#define CMD_SET_PHOTO_IN 520
#define CMD_SET_PHOTO_OUT 515
#define CMD_SET_ADC_ENABLE 500
#define CMD_SET_MIPI_SWITCH 501
#define CMD_SET_CAM_RSTN1 502
#define CMD_SET_CAM_RSTN0 503
#define CMD_SET_SD_DECT 507
#define CMD_SET_PTZ_PWR_ENABLE 508
#define CMD_SET_RTC_ENABLE 511
#define CMD_SET_100M_ENABLE 518
#define CMD_SET_100M_SWITCH_PWR_ENABLE 519
#define CMD_SET_AM_POWER_ENABLE 521
#define CMD_SET_NRSEC_POWER_ENABLE 522
#define CMD_SET_AMP_ENABLE 523
#define CMD_SET_LIGHT1_RESISTOR_ENABLE 524
#define CMD_SET_100M_RESET 526
#endif // USING_PLZ
#else // defined(USING_N938)
#if 1 //云台
#define CMD_SET_485_ENABLE 512
#define CMD_SET_3V3_PWR_ENABLE 516
#define CMD_SET_5V_PWR_ENABLE 517
#define CMD_SET_SENSOR_ENABLE 504
#define CMD_SET_SENSOR_PWR_ENABLE 505
#define CMD_SET_SENSOR2_ENABLE 506
#define CMD_SET_SENSOR4_ENABLE 510
#define CMD_SET_SENSOR1_PWR_ENABLE 513
#define CMD_SET_SENSOR2_PWR_ENABLE 514
#define CMD_SET_SENSOR3_PWR_ENABLE 509
#define CMD_SET_SENSOR4_PWR_ENABLE 525
#define CMD_SET_PHOTO_IN 520
#define CMD_SET_PHOTO_OUT 515
#define CMD_SET_ADC_ENABLE 500
#define CMD_SET_MIPI_SWITCH 501
#define CMD_SET_CAM_RSTN1 502
#define CMD_SET_CAM_RSTN0 503
#define CMD_SET_SD_DECT 507
#define CMD_SET_PTZ_PWR_ENABLE 508
#define CMD_SET_RTC_ENABLE 511
#define CMD_SET_100M_ENABLE 518
#define CMD_SET_100M_SWITCH_PWR_ENABLE 519
#define CMD_SET_AM_POWER_ENABLE 521
#define CMD_SET_NRSEC_POWER_ENABLE 522
#define CMD_SET_AMP_ENABLE 523
#define CMD_SET_LIGHT1_RESISTOR_ENABLE 524
#define CMD_SET_100M_RESET 526
#endif
#if 0 //微拍
#define CMD_SET_485_EN_STATE 131
#define CMD_SET_CAM_3V3_EN_STATE 132
#define CMD_SET_12V_EN_STATE 133
#define CMD_SET_485_STATE 121
#define CMD_SET_SPI_MODE 123
#define CMD_SET_SPI_BITS_PER_WORD 124
#define CMD_SET_SPI_MAXSPEEDHZ 125
#define CMD_SET_SPI_POWER 129
#define CMD_SET_WTH_POWER 490
#define CMD_SET_PULL_POWER 491
#define CMD_SET_ANGLE_POWER 492
#define CMD_SET_OTHER_POWER 493
#define CMD_SET_PIC1_POWER 494
#define CMD_SET_GPIO157_POWER 510
#define CMD_SET_GPIO5_POWER 511
#define CMD_SET_PWM_BEE_STATE 126
#define CMD_SET_ALM_MODE 128
#define CMD_SET_485_en0 301
#define CMD_SET_485_en1 302
#define CMD_SET_485_en2 303
#define CMD_SET_485_en3 304
#define CMD_SET_485_en4 305
#define CMD_SET_OTG_STATE 107
#define CMD_GET_OTG_STATE 108
#else //938
#define CMD_SET_485_en1 302
//#define CMD_SET_CAM_3V3_EN_STATE 360
#define CMD_SET_SYSTEM_RESET 202
#define CMD_SET_485_EN1 302
#define CMD_SET_CAM_3V3_EN_STATE 360
#define CMD_SET_UART0_EN 361
#define CMD_SET_485_en0 301
#define CMD_SET_485_EN0 301
#define CMD_SET_NETWORK_POWER_EN 362
#define CMD_SET_485_en3 304
#define CMD_SET_485_EN3 304
#define CMD_SET_485_en2 303
#define CMD_SET_SPI_POWER 129
#define CMD_SET_5V_EN 363
@ -124,56 +107,9 @@
#define CMD_ADC_EN 367
#define CMD_SPI2SERIAL_POWER_EN 368
#define CMD_RS485_3V3_EN 369
#endif
#if 0
#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_STATE1 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信号
#define CMD_NETWORK_PWR_EN 94 // 100M网络电源使能
#define CMD_485_2_PWR_EN 92 // 485_2 电源使能
#define CMD_485_3_PWR_EN 91 // 485_3 电源使能
#define CMD_485_4_PWR_EN 90 // 485_4 电源使能
#define CMD_SEC_EN 27 // 加密芯片上电使能
#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
#endif // USING_N938
#define CMD_OTHER_EN 21
#define CMD_ANGLE_EN 22
#define CMD_PULL_EN 23
#define CMD_WEATHER_EN 24
#define CMD_LED_CTRL 46
#define CMD_BD_EN 47
#define CMD_ADC_EN 44
#define CMD_SPI_PWR_EN 43 // SPI转串口电源使能
#endif
#ifdef USING_N938
#define GPIO_NODE_N938 "/sys/devices/platform/1000b000.pinctrl/mt_gpio"
#else
#endif // USING_N938
#define GPIO_NODE_MP "/dev/mtkgpioctrl"
@ -194,12 +130,18 @@ public:
static void setOtgState(bool on)
{
#ifndef USING_N938
setInt(CMD_SET_OTG_STATE, on ? 1 : 0);
#endif
}
static bool getOtgState()
{
#ifndef USING_N938
return getInt(CMD_SET_OTG_STATE) != 0;
#else
return false;
#endif
}
static void setCam3V3Enable(bool enabled)
@ -218,82 +160,142 @@ public:
static void setLightAdc(int i)
{
#ifndef USING_N938
setInt(CMD_SET_LIGHT_ADC, i);
#endif
}
static int getLightAdc()
{
#ifndef USING_N938
return getInt(CMD_GET_LIGHT_ADC);
#else
return -1;
#endif
}
static int getChargingVoltage()
{
#ifndef USING_N938
return getInt(CMD_GET_CHARGING_VOL_STATE);
#else
return -1;
#endif
}
static int getChargingShuntVoltage()
{
#ifndef USING_N938
return getInt(CMD_GET_CHARGING_SHUNT_VOLTAGE_STATE);
#else
return -1;
#endif
}
static int getChargingBusVoltage() {
#ifndef USING_N938
return getInt(CMD_GET_CHARGING_BUS_VOLTAGE_STATE);
#else
return -1;
#endif
}
static int getChargingPower() {
#ifndef USING_N938
return getInt(CMD_GET_CHARGING_POWER_STATE);
#else
return -1;
#endif
}
static int getChargingCurrent() {
#ifndef USING_N938
return getInt(CMD_GET_CHARGING_CURRENT_STATE);
#else
return -1;
#endif
}
static int getBatteryVoltage() {
#ifndef USING_N938
return getInt(CMD_GET_BAT_VOL_STATE);
#else
return -1;
#endif
}
static int getBatteryShuntVoltage() {
#ifndef USING_N938
return getInt(CMD_GET_BAT_SHUNT_VOLTAGE_STATE);
#else
return -1;
#endif
}
static int getBatteryBusVoltage() {
#ifndef USING_N938
return getInt(CMD_GET_BAT_BUS_VOLTAGE_STATE);
#else
return -1;
#endif
}
static int getBatteryPower() {
#ifndef USING_N938
return getInt(CMD_GET_BAT_POWER_STATE);
#else
return -1;
#endif
}
static int getBatteryCurrent() {
#ifndef USING_N938
return getInt(CMD_GET_BAT_CURRENT_STATE);
#else
return -1;
#endif
}
static void set485WriteMode() {
#if 0
setInt(CMD_SET_485_STATE, 1);
#endif
}
static void set485ReadMode() {
#if 0
setInt(CMD_SET_485_STATE, 0);
#endif
}
static void setSpiMode(int i) {
#ifndef USING_N938
setInt(CMD_SET_SPI_MODE, i);
#endif
}
static void setSpiBitsPerWord(int i) {
#ifndef USING_N938
setInt(CMD_SET_SPI_BITS_PER_WORD, i);
#endif
}
static void setSpiMaxSpeedHz(long j) {
#ifndef USING_N938
setLong(CMD_SET_SPI_MAXSPEEDHZ, j);
#endif
}
static void setBeeOn(bool z) {
#ifndef USING_N938
setInt(CMD_SET_PWM_BEE_STATE, z ? 1 : 0);
#endif
}
static void setJidianqiState(bool z) {
#ifndef USING_N938
setInt(CMD_SET_ALM_MODE, z ? 1 : 0);
#endif
}
static void setSpiPower(bool on) {
@ -305,12 +307,16 @@ public:
}
static void setRS485Enable(bool z) {
#ifndef USING_N938
setInt(CMD_SET_485_EN_STATE, z ? 1 : 0);
#endif
}
static void set12VEnable(bool z) {
#ifndef USING_N938
setInt(CMD_SET_12V_EN_STATE, z ? 1 : 0);
#endif
}
};

@ -3237,7 +3237,12 @@ bool CPhoneDevice::OpenSensors(int sensortype)
GpioControl::setCam3V3Enable(true);
GpioControl::setRS485Enable(true);
// GpioControl::setInt(CMD_SET_485_EN_STATE, 1); // 打开RS485电源
#ifndef USING_N938
GpioControl::setInt(CMD_SET_485_ENABLE, 1);
#else
GpioControl::setInt(CMD_SPI2SERIAL_POWER_EN, 1);
GpioControl::setInt(CMD_RS485_3V3_EN, 1);
#endif
GpioControl::setInt(CMD_SET_SPI_POWER, 1);
}
if(sensortype == CAMERA_SENSOR_OPEN)
@ -3245,20 +3250,22 @@ bool CPhoneDevice::OpenSensors(int sensortype)
GpioControl::setInt(CMD_SET_PIC1_POWER, 1);
GpioControl::setInt(CMD_SET_485_en4, 1);
// GpioControl::setInt(CMD_SET_CAM_3V3_EN_STATE, 1); // 打开3.3V电压
GpioControl::setInt(CMD_SET_3V3_PWR_ENABLE, 1);
// GpioControl::setInt(CMD_SET_3V3_PWR_ENABLE, 1);
#ifndef USING_N938
GpioControl::setInt(CMD_SET_PTZ_PWR_ENABLE, 1);
#endif
}
if(sensortype == WEATHER_SENSOR_OPEN || sensortype == ICETHICK_SENSOR_OPEN)
{
GpioControl::setInt(CMD_SET_WTH_POWER, 1);
GpioControl::setInt(CMD_SET_485_en3, 1);
GpioControl::setInt(CMD_SET_485_EN3, 1);
}
if(sensortype == ICETHICK_SENSOR_OPEN)
{
GpioControl::setInt(CMD_SET_PULL_POWER, 1);
GpioControl::setInt(CMD_SET_ANGLE_POWER, 1);
GpioControl::setInt(CMD_SET_485_en1, 1);
GpioControl::setInt(CMD_SET_485_en0, 1);
GpioControl::setInt(CMD_SET_485_EN1, 1);
GpioControl::setInt(CMD_SET_485_EN0, 1);
}
if(sensortype == OTHER_SENSOR)
{
@ -3277,7 +3284,12 @@ bool CPhoneDevice::CloseSensors(int sensortype)
GpioControl::setCam3V3Enable(false);
GpioControl::setRS485Enable(false);
// GpioControl::setInt(CMD_SET_485_EN_STATE, 0);
#ifndef USING_N938
GpioControl::setInt(CMD_SET_485_ENABLE, 0);
#else
GpioControl::setInt(CMD_SPI2SERIAL_POWER_EN, 0);
GpioControl::setInt(CMD_RS485_3V3_EN, 0);
#endif
}
if(sensortype == CAMERA_SENSOR_OPEN)
@ -3285,20 +3297,22 @@ bool CPhoneDevice::CloseSensors(int sensortype)
GpioControl::setInt(CMD_SET_PIC1_POWER, 0);
GpioControl::setInt(CMD_SET_485_en4, 0);
// GpioControl::setInt(CMD_SET_CAM_3V3_EN_STATE, 0);
#ifndef USING_N938
GpioControl::setInt(CMD_SET_3V3_PWR_ENABLE, 0);
GpioControl::setInt(CMD_SET_PTZ_PWR_ENABLE, 0);
#endif
}
if(sensortype == WEATHER_SENSOR_OPEN || sensortype == ICETHICK_SENSOR_OPEN)
{
GpioControl::setInt(CMD_SET_WTH_POWER, 0);
GpioControl::setInt(CMD_SET_485_en3, 0);
GpioControl::setInt(CMD_SET_485_EN3, 0);
}
if(sensortype == ICETHICK_SENSOR_OPEN)
{
GpioControl::setInt(CMD_SET_PULL_POWER, 0);
GpioControl::setInt(CMD_SET_ANGLE_POWER, 0);
GpioControl::setInt(CMD_SET_485_en1, 0);
GpioControl::setInt(CMD_SET_485_en0, 0);
GpioControl::setInt(CMD_SET_485_EN1, 0);
GpioControl::setInt(CMD_SET_485_EN0, 0);
}
if(sensortype == OTHER_SENSOR)
{

@ -70,18 +70,26 @@ int getInt(int cmd)
}
static void setRS485Enable(bool z) {
#ifndef USING_N938
setInt(CMD_SET_485_EN_STATE, z ? 1 : 0);
#endif
}
static void set485WriteMode() {
#ifndef USING_N938
setInt(CMD_SET_485_STATE, 1);
#endif
}
static void set485ReadMode() {
#ifndef USING_N938
setInt(CMD_SET_485_STATE, 0);
#endif
}
static void set12VEnable(bool z) {
#ifndef USING_N938
setInt(CMD_SET_12V_EN_STATE, z ? 1 : 0);
#endif
}
static void setCam3V3Enable(bool enabled)
@ -595,24 +603,24 @@ void Gm_CloseSensorsPower()
#endif
#if 1
setInt(CMD_SET_SPI_POWER, 1);
setInt(CMD_SET_485_en0, 1);
setInt(CMD_SET_485_en1, 1);
setInt(CMD_SET_485_EN0, 1);
setInt(CMD_SET_485_EN1, 1);
setInt(CMD_SET_485_en2, 1);
setInt(CMD_SET_485_en3, 1);
setInt(CMD_SET_485_EN3, 1);
setInt(CMD_SET_485_en4, 1);
#else
setInt(CMD_SET_SPI_POWER, 0);
setInt(CMD_SET_485_en0, 0);
setInt(CMD_SET_485_en1, 0);
setInt(CMD_SET_485_EN0, 0);
setInt(CMD_SET_485_EN1, 0);
setInt(CMD_SET_485_en2, 0);
setInt(CMD_SET_485_en3, 0);
setInt(CMD_SET_485_EN3, 0);
setInt(CMD_SET_485_en4, 0);
sleep(3);
igpio = getInt(CMD_SET_SPI_POWER);
igpio = getInt(CMD_SET_485_en0);
igpio = getInt(CMD_SET_485_en1);
igpio = getInt(CMD_SET_485_EN0);
igpio = getInt(CMD_SET_485_EN1);
igpio = getInt(CMD_SET_485_en2);
igpio = getInt(CMD_SET_485_en3);
igpio = getInt(CMD_SET_485_EN3);
igpio = getInt(CMD_SET_485_en4);
#endif
*/
@ -655,25 +663,25 @@ void Gm_OpenSensorsPower()
#endif
#if 1
setInt(CMD_SET_SPI_POWER, 1);
setInt(CMD_SET_485_en0, 1);
setInt(CMD_SET_485_en1, 1);
setInt(CMD_SET_485_EN0, 1);
setInt(CMD_SET_485_EN1, 1);
setInt(CMD_SET_485_en2, 1);
setInt(CMD_SET_485_en3, 1);
setInt(CMD_SET_485_EN3, 1);
setInt(CMD_SET_485_en4, 1);
//sleep(3);
igpio = getInt(CMD_SET_SPI_POWER);
igpio = getInt(CMD_SET_485_en0);
igpio = getInt(CMD_SET_485_en1);
igpio = getInt(CMD_SET_485_EN0);
igpio = getInt(CMD_SET_485_EN1);
igpio = getInt(CMD_SET_485_en2);
igpio = getInt(CMD_SET_485_en3);
igpio = getInt(CMD_SET_485_EN3);
igpio = getInt(CMD_SET_485_en4);
#else
setInt(CMD_SET_485_en0, 0);
setInt(CMD_SET_485_en1, 0);
setInt(CMD_SET_485_EN0, 0);
setInt(CMD_SET_485_EN1, 0);
setInt(CMD_SET_485_en2, 0);
setInt(CMD_SET_485_en3, 0);
setInt(CMD_SET_485_EN3, 0);
setInt(CMD_SET_485_en4, 0);
#endif

Loading…
Cancel
Save