Merge "[Feature][ZXW-151] add T106E-gnss code,GPS chip is HD8122"
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h
index dfced9c..d512dc1 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h
@@ -7,7 +7,6 @@
extern "C" {
#endif
-
/*
GGA: GNSS 定位数据
$GNGGA,,,,,,0,00,99.99,,,,,,*56
@@ -272,12 +271,13 @@
+
static struct mopen_gnss_device_info_t mopen_gnss_device_info;
static struct mbtk_gnss_handle_t *mbtk_gnss_handle = NULL;
static int firmware_extren_state = 0;
static char g_no_sv = 0;// 参与定位的卫星数量
-
+extern int gpio21_value;
int mopen_gnss_get_nmea_config(uint32 h_gnss);
int mopen_gnss_get_ant_state_info(uint32 h_gnss);
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp
index 326f697..8884a7a 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp
@@ -132,7 +132,6 @@
lynq_gnss_get_aidinfo(h_gnss);
return 0;
}
-
int qser_Gnss_Start(uint32_t h_gnss)
{
struct mbtk_gnss_handle_t *gnss_handle = (struct mbtk_gnss_handle_t *)h_gnss;
@@ -143,10 +142,22 @@
g_gnss_sync_done = 0;
lynq_open_gps(1);
- ret = set_baudrate(gnss_handle->dev_fd, B9600);
- if(-1 == ret)
+ ALOGE("GNSS_VALUE: %d\n",gpio21_value);
+ if(gpio21_value == 1)
{
- return -2;
+ ret = set_baudrate(gnss_handle->dev_fd, B115200);
+ if(-1 == ret)
+ {
+ return -2;
+ }
+ }
+ else if(gpio21_value == 0)
+ {
+ ret = set_baudrate(gnss_handle->dev_fd, B9600);
+ if(-1 == ret)
+ {
+ return -2;
+ }
}
return 0;
}
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
index 7afec28..e7dba8f 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
@@ -890,14 +890,37 @@
return -1;
}
-
-#define GPS_DEV "/sys/devices/soc.0/d4000000.apb/mbtk-dev-op/gps_power"
-
+int gpio21_value = -1;
int lynq_open_gps(int state)
{
- char cmd[128] = "echo '86' > /sys/class/gpio/export && cd /sys/class/gpio/gpio86";
int ret;
+ int cn_enable = 86;
+ int eur_enable = 84;
+ int eur_boot = 15;
+ char compare_buf[256] = {0};
+ const char* compare_cmd = "echo '21' > /sys/class/gpio/export && cat /sys/class/gpio/gpio21/value";
+ exec_cmd(compare_cmd,compare_buf);
+ gpio21_value = (compare_buf[0] - '0');
+ const char*compare_cmd2 = "echo '21' > /sys/class/gpio/unexport";
+ exec_cmd(compare_cmd2,NULL);
+ /*this is CN GPIO*/
+ char CN_Enable[128];
+ sprintf(CN_Enable,"echo '%d' > /sys/class/gpio/export && cd /sys/class/gpio/gpio%d", cn_enable,cn_enable);
+
+ /*this is Europe GPIO*/
+ char Eur_Boot[128];
+ sprintf(Eur_Boot,"echo '%d' > /sys/class/gpio/export && cd /sys/class/gpio/gpio%d", eur_boot,eur_boot);
+ char Eur_Enable[128];
+ sprintf(Eur_Enable,"echo '%d' > /sys/class/gpio/export && cd /sys/class/gpio/gpio%d", eur_enable,eur_enable);
+
+ char CN_Enable_unexport[128];
+ sprintf(CN_Enable_unexport,"echo '%d' > /sys/class/gpio/unexport", cn_enable);
+ char Eur_Boot_unexport[128];
+ sprintf(Eur_Boot_unexport,"echo '%d' > /sys/class/gpio/unexport", eur_boot);
+ char Eur_Enable_unexport[128];
+ sprintf(Eur_Enable_unexport,"echo '%d' > /sys/class/gpio/unexport", eur_enable);
+
if(0 == state)
{
nmea_state = 0;
@@ -909,35 +932,107 @@
}
usleep(10000);
}
- ret = exec_cmd(cmd,NULL);
- if(0 != ret)
+
+ if(gpio21_value == 1)
{
- printf("stop fail %x\n", ret);
+ ret = exec_cmd(Eur_Boot,NULL);
+ if(ret < 0)
+ {
+ return -1;
+ }
+ ret = exec_cmd(Eur_Enable,NULL);
+ if(ret < 0)
+ {
+ return -1;
+ }
+
}
- char cmd2[128] = "echo '0' > /sys/class/gpio/gpio86/value && echo '86' > /sys/class/gpio/unexport";
- ret = exec_cmd(cmd2,NULL);
- if(0 != ret)
+ else if(gpio21_value == 0)
{
- printf("stop fail %x\n", ret);
- }
+ ret = exec_cmd(CN_Enable,NULL);
+ if(ret < 0)
+ {
+ return -1;
+ }
+ }
+
+ const char* CN_Enable2 = "echo '0' > /sys/class/gpio/gpio86/value";
+ char Eur_Boot2[128];
+ sprintf(Eur_Boot2,"echo 'out' > /sys/class/gpio/gpio%d/direction && echo '0' > /sys/class/gpio/gpio%d/value",eur_boot,eur_boot);
+ char Eur_Enable2[128];
+ sprintf(Eur_Enable2,"echo 'out' > /sys/class/gpio/gpio%d/direction && echo '0' > /sys/class/gpio/gpio%d/value",eur_enable,eur_enable);
+ if(gpio21_value == 1)
+ {
+ exec_cmd(Eur_Boot2,NULL);
+ exec_cmd(Eur_Enable2,NULL);
+ exec_cmd(Eur_Boot_unexport,NULL);
+ exec_cmd(Eur_Enable_unexport,NULL);
+
+ }
+ else if(gpio21_value == 0)
+ {
+ ret = exec_cmd(CN_Enable2,NULL);
+ if(ret < 0)
+ {
+ return -1;
+ }
+ ret = exec_cmd(CN_Enable_unexport,NULL);
+ if(ret < 0)
+ {
+ return -1;
+ }
+ }
}
- if(1 == state)
+ else if(1 == state)
{
nmea_state = 1;
-
- ret = exec_cmd(cmd,NULL);
- if(0 != ret)
+ if(gpio21_value == 1)
{
- printf("start fail %x\n", ret);
- return -1;
+ ret = exec_cmd(Eur_Boot,NULL);
+ if(ret < 0)
+ {
+ return -1;
+ }
+ ret = exec_cmd(Eur_Enable,NULL);
+ if(ret < 0)
+ {
+ return -1;
+ }
}
- char cmd3[128] = "echo '1' > /sys/class/gpio/gpio86/value && echo '86' > /sys/class/gpio/unexport";
- ret = exec_cmd(cmd3,NULL);
- if(0 != ret)
+ else if(gpio21_value == 0)
{
- printf("start fail %x\n", ret);
- return -1;
+ ret = exec_cmd(CN_Enable,NULL);
+ if(ret < 0)
+ {
+ return -1;
+ }
+ }
+ char CN_Enable3[128] = "echo '1' > /sys/class/gpio/gpio86/value";
+ char Eur_Boot3[128];
+ sprintf(Eur_Boot3,"echo 'out' > /sys/class/gpio/gpio%d/direction && echo '1' > /sys/class/gpio/gpio%d/value",eur_boot,eur_boot);
+ char Eur_Enable3[128];
+ sprintf(Eur_Enable3,"echo 'out' > /sys/class/gpio/gpio%d/direction && echo '1' > /sys/class/gpio/gpio%d/value",eur_enable,eur_enable);
+ if(gpio21_value == 1)
+ {
+ exec_cmd(Eur_Boot3,NULL);
+ exec_cmd(Eur_Enable3,NULL);
+ exec_cmd(Eur_Boot_unexport,NULL);
+ exec_cmd(Eur_Enable_unexport,NULL);
+
+ }
+ else if(gpio21_value == 0)
+ {
+ ret = exec_cmd(CN_Enable3,NULL);
+ if(ret < 0)
+ {
+ return -1;
+ }
+ ret = exec_cmd(CN_Enable_unexport,NULL);
+ if(ret < 0)
+ {
+ return -1;
+ }
}
}
return 0;
@@ -1495,9 +1590,11 @@
{
if(fgets(buffer, 256, pipe))
{
+ result[0] = buffer[0];
memset(buffer, 0, sizeof(buffer));
}
}
+
pclose(pipe);
return 0;
}