|
|
@ -12,6 +12,12 @@
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
#include <utility>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef USING_PLZ // MicroPhoto
|
|
|
|
|
|
|
|
|
|
|
|
#define CMD_GET_LIGHT_ADC 101
|
|
|
|
#define CMD_GET_LIGHT_ADC 101
|
|
|
|
#define CMD_SET_LIGHT_ADC 102
|
|
|
|
#define CMD_SET_LIGHT_ADC 102
|
|
|
|
#define CMD_GET_KEY_LOCKSTATE 103
|
|
|
|
#define CMD_GET_KEY_LOCKSTATE 103
|
|
|
@ -44,8 +50,8 @@
|
|
|
|
#define CMD_SET_CAM_3V3_EN_STATE 132
|
|
|
|
#define CMD_SET_CAM_3V3_EN_STATE 132
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#else // defined(USING_PLZ)
|
|
|
|
|
|
|
|
|
|
|
|
#if 1 //云台
|
|
|
|
|
|
|
|
#define CMD_SET_485_ENABLE 512
|
|
|
|
#define CMD_SET_485_ENABLE 512
|
|
|
|
#define CMD_SET_3V3_PWR_ENABLE 516
|
|
|
|
#define CMD_SET_3V3_PWR_ENABLE 516
|
|
|
|
#define CMD_SET_5V_PWR_ENABLE 517
|
|
|
|
#define CMD_SET_5V_PWR_ENABLE 517
|
|
|
@ -74,41 +80,18 @@
|
|
|
|
#define CMD_SET_AMP_ENABLE 523
|
|
|
|
#define CMD_SET_AMP_ENABLE 523
|
|
|
|
#define CMD_SET_LIGHT1_RESISTOR_ENABLE 524
|
|
|
|
#define CMD_SET_LIGHT1_RESISTOR_ENABLE 524
|
|
|
|
#define CMD_SET_100M_RESET 526
|
|
|
|
#define CMD_SET_100M_RESET 526
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0 //微拍
|
|
|
|
#endif // USING_PLZ
|
|
|
|
#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
|
|
|
|
#else // defined(USING_N938)
|
|
|
|
#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_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_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_485_en2 303
|
|
|
|
#define CMD_SET_SPI_POWER 129
|
|
|
|
#define CMD_SET_SPI_POWER 129
|
|
|
|
#define CMD_SET_5V_EN 363
|
|
|
|
#define CMD_SET_5V_EN 363
|
|
|
@ -124,57 +107,10 @@
|
|
|
|
#define CMD_ADC_EN 367
|
|
|
|
#define CMD_ADC_EN 367
|
|
|
|
#define CMD_SPI2SERIAL_POWER_EN 368
|
|
|
|
#define CMD_SPI2SERIAL_POWER_EN 368
|
|
|
|
#define CMD_RS485_3V3_EN 369
|
|
|
|
#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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
#endif // USING_N938
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define GPIO_NODE_MP "/dev/mtkgpioctrl"
|
|
|
|
#define GPIO_NODE_MP "/dev/mtkgpioctrl"
|
|
|
|
|
|
|
|
|
|
|
|
class GpioControl
|
|
|
|
class GpioControl
|
|
|
@ -194,12 +130,18 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
static void setOtgState(bool on)
|
|
|
|
static void setOtgState(bool on)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
setInt(CMD_SET_OTG_STATE, on ? 1 : 0);
|
|
|
|
setInt(CMD_SET_OTG_STATE, on ? 1 : 0);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool getOtgState()
|
|
|
|
static bool getOtgState()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
return getInt(CMD_SET_OTG_STATE) != 0;
|
|
|
|
return getInt(CMD_SET_OTG_STATE) != 0;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void setCam3V3Enable(bool enabled)
|
|
|
|
static void setCam3V3Enable(bool enabled)
|
|
|
@ -218,82 +160,142 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
static void setLightAdc(int i)
|
|
|
|
static void setLightAdc(int i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
setInt(CMD_SET_LIGHT_ADC, i);
|
|
|
|
setInt(CMD_SET_LIGHT_ADC, i);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int getLightAdc()
|
|
|
|
static int getLightAdc()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
return getInt(CMD_GET_LIGHT_ADC);
|
|
|
|
return getInt(CMD_GET_LIGHT_ADC);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int getChargingVoltage()
|
|
|
|
static int getChargingVoltage()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
return getInt(CMD_GET_CHARGING_VOL_STATE);
|
|
|
|
return getInt(CMD_GET_CHARGING_VOL_STATE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int getChargingShuntVoltage()
|
|
|
|
static int getChargingShuntVoltage()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
return getInt(CMD_GET_CHARGING_SHUNT_VOLTAGE_STATE);
|
|
|
|
return getInt(CMD_GET_CHARGING_SHUNT_VOLTAGE_STATE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int getChargingBusVoltage() {
|
|
|
|
static int getChargingBusVoltage() {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
return getInt(CMD_GET_CHARGING_BUS_VOLTAGE_STATE);
|
|
|
|
return getInt(CMD_GET_CHARGING_BUS_VOLTAGE_STATE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int getChargingPower() {
|
|
|
|
static int getChargingPower() {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
return getInt(CMD_GET_CHARGING_POWER_STATE);
|
|
|
|
return getInt(CMD_GET_CHARGING_POWER_STATE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int getChargingCurrent() {
|
|
|
|
static int getChargingCurrent() {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
return getInt(CMD_GET_CHARGING_CURRENT_STATE);
|
|
|
|
return getInt(CMD_GET_CHARGING_CURRENT_STATE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int getBatteryVoltage() {
|
|
|
|
static int getBatteryVoltage() {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
return getInt(CMD_GET_BAT_VOL_STATE);
|
|
|
|
return getInt(CMD_GET_BAT_VOL_STATE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int getBatteryShuntVoltage() {
|
|
|
|
static int getBatteryShuntVoltage() {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
return getInt(CMD_GET_BAT_SHUNT_VOLTAGE_STATE);
|
|
|
|
return getInt(CMD_GET_BAT_SHUNT_VOLTAGE_STATE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int getBatteryBusVoltage() {
|
|
|
|
static int getBatteryBusVoltage() {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
return getInt(CMD_GET_BAT_BUS_VOLTAGE_STATE);
|
|
|
|
return getInt(CMD_GET_BAT_BUS_VOLTAGE_STATE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int getBatteryPower() {
|
|
|
|
static int getBatteryPower() {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
return getInt(CMD_GET_BAT_POWER_STATE);
|
|
|
|
return getInt(CMD_GET_BAT_POWER_STATE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int getBatteryCurrent() {
|
|
|
|
static int getBatteryCurrent() {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
return getInt(CMD_GET_BAT_CURRENT_STATE);
|
|
|
|
return getInt(CMD_GET_BAT_CURRENT_STATE);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void set485WriteMode() {
|
|
|
|
static void set485WriteMode() {
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
setInt(CMD_SET_485_STATE, 1);
|
|
|
|
setInt(CMD_SET_485_STATE, 1);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void set485ReadMode() {
|
|
|
|
static void set485ReadMode() {
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
setInt(CMD_SET_485_STATE, 0);
|
|
|
|
setInt(CMD_SET_485_STATE, 0);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void setSpiMode(int i) {
|
|
|
|
static void setSpiMode(int i) {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
setInt(CMD_SET_SPI_MODE, i);
|
|
|
|
setInt(CMD_SET_SPI_MODE, i);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void setSpiBitsPerWord(int i) {
|
|
|
|
static void setSpiBitsPerWord(int i) {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
setInt(CMD_SET_SPI_BITS_PER_WORD, i);
|
|
|
|
setInt(CMD_SET_SPI_BITS_PER_WORD, i);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void setSpiMaxSpeedHz(long j) {
|
|
|
|
static void setSpiMaxSpeedHz(long j) {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
setLong(CMD_SET_SPI_MAXSPEEDHZ, j);
|
|
|
|
setLong(CMD_SET_SPI_MAXSPEEDHZ, j);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void setBeeOn(bool z) {
|
|
|
|
static void setBeeOn(bool z) {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
setInt(CMD_SET_PWM_BEE_STATE, z ? 1 : 0);
|
|
|
|
setInt(CMD_SET_PWM_BEE_STATE, z ? 1 : 0);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void setJidianqiState(bool z) {
|
|
|
|
static void setJidianqiState(bool z) {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
setInt(CMD_SET_ALM_MODE, z ? 1 : 0);
|
|
|
|
setInt(CMD_SET_ALM_MODE, z ? 1 : 0);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void setSpiPower(bool on) {
|
|
|
|
static void setSpiPower(bool on) {
|
|
|
@ -305,12 +307,16 @@ public:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void setRS485Enable(bool z) {
|
|
|
|
static void setRS485Enable(bool z) {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
setInt(CMD_SET_485_EN_STATE, z ? 1 : 0);
|
|
|
|
setInt(CMD_SET_485_EN_STATE, z ? 1 : 0);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void set12VEnable(bool z) {
|
|
|
|
static void set12VEnable(bool z) {
|
|
|
|
|
|
|
|
#ifndef USING_N938
|
|
|
|
setInt(CMD_SET_12V_EN_STATE, z ? 1 : 0);
|
|
|
|
setInt(CMD_SET_12V_EN_STATE, z ? 1 : 0);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|