greeneye2_common.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. /******************************************************************************
  2. ** File Name: greeneye2_common.h *
  3. ** Author: *
  4. ** DATE: *
  5. ** Copyright: 2002 Spreatrum, Incoporated. All Rights Reserved. *
  6. ** Description: *
  7. ******************************************************************************
  8. ******************************************************************************
  9. ** Edit History *
  10. ** ------------------------------------------------------------------------- *
  11. ** DATE NAME DESCRIPTION *
  12. ** * *
  13. ******************************************************************************/
  14. #ifndef GREENEYE2_COMMON_H
  15. #define GREENEYE2_COMMON_H
  16. /**---------------------------------------------------------------------------*
  17. ** Dependencies *
  18. **---------------------------------------------------------------------------*/
  19. #include "greeneye2.h"
  20. #include "greeneye2_type.h"
  21. #include "greeneye2_gnss_libgps_api.h"
  22. #include "sci_types.h"
  23. //#include "nv_item_id.h"
  24. #include "nvitem.h"
  25. //#include "caliparam.h"
  26. //#include "msensor_drv.h"
  27. #include "greeneye2_nmeaenc.h"
  28. //#include "task_monitor.h"
  29. #include "gnss_driver_api.h"
  30. #include "pam_config.h"
  31. #include <stdio.h>
  32. #include <limits.h>
  33. /**---------------------------------------------------------------------------*
  34. ** Compiler Flag *
  35. **---------------------------------------------------------------------------*/
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. /**---------------------------------------------------------------------------*
  40. ** Constant Variables *
  41. **---------------------------------------------------------------------------*/
  42. /**---------------------------------------------------------------------------*
  43. ** Data Structures *
  44. **---------------------------------------------------------------------------*/
  45. extern osiThread_t *pamGetTaskID(void);
  46. #ifdef CONFIG_PAM_LTE_GNSS_WIFISCAN_SUPPORT
  47. #define Re_TaskID pamGetTaskID()
  48. #else
  49. #define Re_TaskID NULL
  50. #endif
  51. #define GPS_DEBUG 0
  52. #define GPS_LTE 0
  53. #define AGPS_PARAM_CONFIG
  54. #define AGPS_LTE 1
  55. #define GNSS_REG_WR
  56. #define UPDATE_BIN 0
  57. #define GNSS_DOWNLOAD_OPT 1
  58. #ifdef LOG_TAG
  59. #undef LOG_TAG
  60. #endif
  61. #define GE2_TIMER_SLEEP_INTERVAL 30000
  62. #define LOG_TAG "LIBGPS"
  63. #define LIBGPS_VERSION_STR "LIBGPS_W20.34.5_MOCOR_V1.2.6"
  64. #define CTRL_MODE 1
  65. #define SUPL_MODE 0
  66. #define MAX_NMEA_TOKENS 32
  67. //#define NMEA_MAX_SIZE 1023
  68. #define TOKEN_LEN(tok) (tok.end > tok.p ? tok.end - tok.p : 0)
  69. #define GPS_RECV_MAX_LEN (4294967200UL)
  70. #define GPS_SEND_MAX_LEN (4294967200UL)
  71. #define POWER_ERROR_NUMBER_MAX (9)
  72. #define SEND_REPEAT_COUNT_MAX (3)
  73. //for boot add by zxw
  74. #define START_DOWNLOAD_FD1 0x01
  75. #define START_DOWNLOAD_GE2 0x02
  76. #define CLOSE_DEVICE 0x03
  77. #define DEVICE_EXCEPTION 0x04
  78. #define DOWNLOAD_FAIL 0x05
  79. #define GET_GNSS_STATUS 0x06
  80. #define GNSS_SOCKET_NAME "gnss_server"
  81. #define WCND_SOCKET_NAME "wcnd"
  82. #define GNSS_DOWNLOAD_TIMEOUT (12) // 6 seconds
  83. #define WCN_CMD_REBOOT_GNSS "rebootgnss"
  84. #define WCN_CMD_DUMP_GNSS "dumpgnss"
  85. #define WCN_CMD_START_GNSS "startgnss"
  86. #define WCN_CMD_STOP_GNSS "stopgnss"
  87. #define WCN_RESP_REBOOT_GNSS "rebootgnss-ok"
  88. #define WCN_RESP_DUMP_GNSS "dumpgnss-ok"
  89. #define WCN_RESP_START_GNSS "startgnss-ok"
  90. #define WCN_RESP_STOP_GNSS "stopgnss-ok"
  91. #define WCN_RESP_STATE_GNSS "gnssstate-ok"
  92. #define GET_XML 0x00
  93. #define SET_XML 0x01
  94. #define SUPL_XML_PATH "/data/gnss/supl/supl.xml"
  95. #define CONFIG_XML_PATH "/data/gnss/config/config.xml"
  96. #define RAWOBS_PATH "/data/gnss/lte/raw.obs"
  97. #define GE2_FDL_PATH "/data/gnss/bin/gnssfdl.bin"
  98. #define SUPL_ETC_PATH "/system/etc/supl.xml"
  99. #define CONFIG_ETC_PATH "/system/etc/config.xml"
  100. #define SPREADORBIT_ETC_PATH "/system/etc/jpleph.405"
  101. #define RAWOBS_ETC_PATH "/system/etc/raw.obs"
  102. #define GE2_FIRMWARE_ETC_PATH "/system/etc/gnssmodem.bin"
  103. #define GE2_FDL_ETC_PATH "/system/etc/gnssfdl.bin"
  104. #define AGNSS_CER_ETC_PATH "/system/etc/spirentroot.cer"
  105. #define FLASHCFG_PATH "/gnss/Flash_GNSS.cg"
  106. /*
  107. // pre defined in
  108. #ifndef GNSS_BASE_PATH
  109. #define GNSS_BASE_PATH L"d:\\others\\gnss"
  110. #endif
  111. */
  112. ///* for tsx */
  113. /*
  114. #ifndef GNSS_TSXDAT_PATH
  115. #define GNSS_TSXDAT_PATH L"d:\\others\\gnss\\tsx.dat"
  116. #endif
  117. #ifndef GNSS_TXTXT_PATH
  118. #define GNSS_TXTXT_PATH L"d:\\others\\gnss\\txdata.txt"
  119. #endif
  120. #ifndef FLASHCFG_GPS_PATH
  121. #define FLASHCFG_GPS_PATH L"d:\\others\\gnss\\FlashCfg_GPS.cg"
  122. #endif
  123. #ifndef FLASHCFG_GLO_PATH
  124. #define FLASHCFG_GLO_PATH L"d:\\others\\gnss\\FlashCfg_GLO.cg"
  125. #endif
  126. #ifndef FLASHCFG_BDS_PATH
  127. #define FLASHCFG_BDS_PATH L"d:\\others\\gnss\\FlashCfg_BDS.cg"
  128. #endif
  129. */
  130. #define SUPL_TYPE 0
  131. #define CONFIG_TYPE 1
  132. #define SPREADORBIT_TYPE 2
  133. #define FIRMWARE_TYPE 3
  134. #define FDL_TYPE 4
  135. #define RAWOBS_TYPE 5
  136. #define CER_TYPE 6
  137. #define PI 3.14159265358979323846
  138. #define WGS_AXIS_A 6378137.0
  139. #define WGS_E1_SQR 0.006694379990141317
  140. #define EARTH_R 6371.004
  141. #ifndef ABS
  142. #define ABS(x) (((x) > 0 ? (x) : -(x)))
  143. #endif
  144. //agps session protection macro and constaint define
  145. #define AGPS_SESSION_START (1)
  146. #define AGPS_SESSION_STOP (2)
  147. #define AGPS_SESSION_TIMEOUT (3)
  148. #define AGPS_GLONASS_EPH_MAX_COUNT (28) //28
  149. #define AGPS_SESSION_TIMEOU_SECONDS (3600) //one hour
  150. #define GPS_WEEK_NO_SECONDS (604800) //one hour
  151. #define TRACE_OFFSET 544 * 1024
  152. #define FORMAT_MAX_LENTH 8
  153. #define LINE_MAX_NUM 2000
  154. #define TSX_DATA_GROUP_NUM_EXT 4
  155. /* Bt mac addr: 6Byte, wifi MAC addr£º 6Byte*/
  156. #define TSX_DATA_CALI_OFFSET (6 + 6)
  157. // for GE2, sync with enum wcn_gnss_sub_sys in kernel
  158. #define GPS_GLONASS_IMG 16 // WCN_GNSS
  159. #define GPS_BDS_IMG 17 // WCN_GNSS_BD
  160. #define NV_STR_GPS_GLO_MODEM "GNSSMODEM"
  161. #define NV_STR_GPS_BDS_MODEM "GNSSBDMODEM"
  162. //gnss work mode constant define
  163. #define GNSS_GPS_WORKMODE (1)
  164. #define GNSS_BD_WORKMODE (2)
  165. #define GNSS_GPS_BD_WORKMODE (3)
  166. #define GNSS_GLONASS_WORKMODE (4)
  167. #define GNSS_GPS_GLONASS_WORKMODE (5)
  168. //for marlin3 default
  169. #define GNSS_GPS_BD2_GLONASS_WORKMODE (7)
  170. //for marlin3 lite default
  171. #define GNSS_GPS_BD2_GALILEO_WORKMODE (19)
  172. #ifdef CONFIG_SOC_8850
  173. //for marlin3 lite integ default
  174. #define GNSS_GPS_B1C_GLONASS_GALILEO_WORKMODE (29)
  175. #endif
  176. //Use RAM buffer to save ephemeris data to Flash
  177. #define USE_RAM_CACHE
  178. /* for tsx begin */
  179. typedef struct
  180. {
  181. float freq;
  182. float temprature;
  183. } TFTable;
  184. typedef struct
  185. {
  186. int freq;
  187. int temprature;
  188. int temprature_osc;
  189. } TSX_DATA_EXT_T; //ap tsx
  190. typedef struct
  191. {
  192. double temprature;
  193. double temprature_osc;
  194. } TSX_TEMP_EXT_T;
  195. typedef struct
  196. {
  197. /*TFTable tsxTable[200];*/
  198. int temprature_diff;
  199. double c0;
  200. double c1;
  201. double c2;
  202. double c3;
  203. double c1_Osc;
  204. double c2_Osc;
  205. double c3_Osc;
  206. double invP[49]; /* 7*7 */
  207. unsigned int validFlag_remain[8];
  208. unsigned int validFlag[4][21];
  209. } TsxData_EXT; //cp tsx
  210. typedef struct
  211. {
  212. int freq;
  213. int temprature;
  214. } TSX_DATA_T;
  215. #define TSX_DATA_GROUP_NUM 2
  216. typedef struct
  217. {
  218. double temprature;
  219. } TSX_TEMP_T;
  220. typedef struct
  221. {
  222. TFTable tsxTable[200];
  223. double c0;
  224. double c1;
  225. double c2;
  226. double c3;
  227. double invP[16];
  228. unsigned int validFlag_remain[8];
  229. unsigned int validFlag[4];
  230. } TsxData;
  231. /* for tsx end */
  232. typedef struct ttf
  233. {
  234. unsigned int weekno;
  235. unsigned int mscount;
  236. } gpstime;
  237. typedef struct
  238. {
  239. int prn;
  240. float snr;
  241. } RawSvData;
  242. typedef struct
  243. {
  244. int num_svs;
  245. RawSvData sv_list[50];
  246. } RawGpsSvInfo;
  247. //RawGpsSvInfo sv_rawinfo;
  248. #if defined(GPS_SUPPORT) && defined(GPS_CHIP_VER_GREENEYE2)
  249. #define NV_GPS_GE2_ITEM_NUM 50
  250. #else
  251. #define NV_GPS_GE2_ITEM_NUM 0
  252. #endif
  253. #define NV_GPS_GE2_BASE_ID (500)
  254. #define NV_GPS_GE2_MAX (NV_GPS_GE2_BASE_ID + NV_GPS_GE2_ITEM_NUM - 1)
  255. #define NV_GPS_GE2_BASE (NV_GPS_GE2_BASE_ID)
  256. typedef enum
  257. {
  258. NV_GPS_AGPS_PARAM = NV_GPS_GE2_BASE,
  259. NV_GPS_EPHEMERIS_PARAM,
  260. NV_GLO_EPHEMERIS_PARAM,
  261. NV_BD_EPHEMERIS_PARAM,
  262. #if 0
  263. NV_GPS_PVTMISC_PARAM,
  264. NV_GPS_GPSEPH1_PARAM,
  265. NV_GPS_GPSEPH2_PARAM,
  266. NV_GPS_GPSEPH3_PARAM,
  267. NV_GPS_GPSEPH4_PARAM,
  268. NV_GPS_GPSALM_PARAM,
  269. NV_GPS_GPSCPY1_PARAM,
  270. NV_GPS_GPSCPY2_PARAM,
  271. NV_GPS_GPSCPY3_PARAM,
  272. NV_GPS_GPSCPY4_PARAM,
  273. NV_GPS_GPSCPY5_PARAM,
  274. NV_GPS_GPSCPY6_PARAM,
  275. NV_GPS_QZSEPH_PARAM,
  276. NV_GPS_BDEPH1_PARAM,
  277. NV_GPS_BDEPH2_PARAM,
  278. NV_GPS_BDALM_PARAM,
  279. NV_GPS_GLOEPH1_PARAM,
  280. NV_GPS_GLOEPH2_PARAM,
  281. NV_GPS_GLOEPH3_PARAM,
  282. NV_GPS_GLOEPH4_PARAM,
  283. NV_GPS_GLOALM1_PARAM,
  284. NV_GPS_GLOALM2_PARAM,
  285. NV_GPS_IONO_PARAM,
  286. NV_GPS_ALMCPY_PARAM,
  287. NV_GPS_SEQLSQ_PARAM,
  288. NV_GPS_BLUNDER_PARAM,
  289. #endif
  290. NV_GPS_MAX_PARAM = NV_GPS_GE2_MAX //must be less than 50
  291. } GPS_FLASHPARAM_T;
  292. //end
  293. typedef enum DevicepowerState
  294. {
  295. DEVICE_DOWNLOADING = 1,
  296. DEVICE_DOWNLOADED,
  297. DEVICE_POWERONING,
  298. DEVICE_POWERONED,
  299. DEVICE_WORKING,
  300. DEVICE_WORKED,
  301. DEVICE_IDLING,
  302. DEVICE_IDLED,
  303. DEVICE_SLEEPING,
  304. DEVICE_SLEEP,
  305. DEVICE_WAKEUPING,
  306. DEVICE_RESET,
  307. DEVICE_POWEROFFING,
  308. DEVICE_POWEROFFED,
  309. DEVICE_ABNORMAL
  310. } TDevicepowerState;
  311. typedef struct
  312. {
  313. const char *p;
  314. const char *end;
  315. } Token;
  316. typedef struct
  317. {
  318. int count;
  319. Token tokens[MAX_NMEA_TOKENS];
  320. } NmeaTokenizer;
  321. #if 0
  322. struct timeout_actions_elem {
  323. int inuse;
  324. int id;
  325. time_t tout;
  326. void (*timeout_cb)(int, void *data);
  327. void *data;
  328. };
  329. #endif
  330. typedef struct
  331. {
  332. int pos;
  333. int overflow;
  334. int utc_year;
  335. int utc_mon;
  336. int utc_day;
  337. GpsLocation fix;
  338. GpsSvStatus svstatus;
  339. int svinfo_flags;
  340. gps_location_callback location_callback;
  341. gps_sv_status_callback sv_status_callback;
  342. char in[NMEA_MAX_SIZE + 1];
  343. } NmeaReader;
  344. typedef enum
  345. {
  346. LIBGPSTYPE,
  347. SUPLTYPE,
  348. CONTROLTYPE,
  349. ENGINETYPE
  350. } GPSTYPE;
  351. typedef enum
  352. {
  353. DUMP_RECV_START_UNKOWN,
  354. DUMP_RECV_CODE_START,
  355. DUMP_RECV_CODE_END, //it qual data start
  356. DUMP_RECV_DATA_END,
  357. DUMP_RECV_MAX,
  358. } DUMP_RecvState_e;
  359. #define SMD_REQ_FLAG_GOOD_SIGNAL 1
  360. #define SMD_REQ_FLAG_BAD_SIGNAL 2
  361. #define SMD_TIMEOUT_VALUE_OF_GOOD_SIGNAL 60
  362. #define SMD_TIMEOUT_VALUE_OF_BAD_SIGNAL 30
  363. #define SMD_RSP_TYPE_OPENED_FAILED 0
  364. #define SMD_RSP_TYPE_OPENED_SUCCESS 1
  365. #define SMD_RSP_TYPE_TIMER_EXPIRED 2
  366. #define SMD_RSP_TYPE_TIMER_NOT_EXPIRED 3
  367. typedef struct
  368. {
  369. char nmea[NMEA_MAX_SIZE + 1];
  370. } OneNmeaMsg_T;
  371. //one GSV sentence including 4 SVs
  372. #define MAX_GSV_SENTENCES (MAX_SV_IN_GSV / 4)
  373. typedef struct
  374. {
  375. OneNmeaMsg_T gga;
  376. OneNmeaMsg_T rmc;
  377. int gsv_count;
  378. OneNmeaMsg_T gsv[MAX_GSV_SENTENCES];
  379. } LastNmeaRecord_T;
  380. typedef struct
  381. {
  382. uint8 isSupportSMD;
  383. uint8 cpSMDReqFlag;
  384. uint8 isStopBySmdTimer;
  385. uint8 isSentOpenSmd;
  386. uint8 smdResponse;
  387. SCI_TIMER_PTR smd_timer;
  388. SCI_TIMER_PTR nmea_timer;
  389. LastNmeaRecord_T lastNmea;
  390. } LowPowerGnss_T;
  391. #define MAX_MINILOG_STR_LINES 1000
  392. #define MINILOG_OFFSET_IN_MODEM_BIN (544 * 1024)
  393. /* DO NOT enlarge this value, it will make GNSS CP crash */
  394. #define MINILOG_MAX_SIZE (48 * 1024)
  395. /* minilog base addr, which saves the minilog loaded from gnssmodem.bin */
  396. #define MINILOG_BASE_ADDR (0x140C00)
  397. #define MAX_LEN_OF_MINILOG_STR (512)
  398. typedef struct
  399. {
  400. char *fmt_str_begin; //format string start address
  401. int len; //format string length
  402. } MinilogStrItem_T;
  403. typedef struct
  404. {
  405. uint8 isLoaded; //is minilog format string loaded or not
  406. uint32 minilog_offset; //minilog format string offset in gnss modem bin
  407. uint32 max_size; //max minilog size
  408. int item_count;
  409. MinilogStrItem_T item_array[MAX_MINILOG_STR_LINES];
  410. } MinilogCtx_T;
  411. #define GNSS_CP_INFO_OFFSET_IN_MODEM_BIN (540 * 1024)
  412. /* before enlarge this value, you should check with GNSS CP side */
  413. #define GNSS_CP_INFO_MAX_SIZE (4 * 1024)
  414. #define GNSS_CP_INFO_KEY_IMG_MODE "GPS-IMG-MODE"
  415. #define GNSS_CP_INFO_KEY_CP_VERSION "GNSS-CP-VERSION"
  416. #define MAX_LEN_OF_GNSS_CP_INFO_VALUE 64
  417. typedef struct
  418. {
  419. uint8 isLoaded; //is loaded or not
  420. uint32 cpInfoOffset; //cp info offset in gnss modem bin
  421. uint32 max_size; //max cp info size
  422. char imgMode[MAX_LEN_OF_GNSS_CP_INFO_VALUE];
  423. char cpVersion[MAX_LEN_OF_GNSS_CP_INFO_VALUE];
  424. } GnssCpInfo_T;
  425. typedef struct
  426. {
  427. //global state value
  428. int init;
  429. int first;
  430. int first_idleoff;
  431. int fd;
  432. int powerctrlfd;
  433. int gnsslogfd;
  434. int slog_switch;
  435. int slogmodem_fd;
  436. int hardware_id;
  437. int getetcconfig;
  438. unsigned char sleepCount;
  439. unsigned char wakeupCount;
  440. char serialName[22]; //fd string name
  441. int uart_port;
  442. //char binPath[128];
  443. // int readBuffersize;
  444. SCI_MUTEX_PTR gnsslogmutex;
  445. SCI_MUTEX_PTR save2flashmutex;
  446. unsigned char readBuffer[SERIAL_READ_BUFFER_MAX];
  447. unsigned char writeBuffer[SERIAL_WRITE_BUFFER_MAX];
  448. unsigned char gnsslogBuffer[GNSS_LOG_BUFFER_MAX];
  449. SCI_SEMAPHORE_PTR gnss_log_sm;
  450. int writeoffsize;
  451. int sendLen;
  452. int sendFlag;
  453. // TCircular_buffer serialWrite;
  454. //pthread_mutex_t writeMutex;
  455. NmeaReader NmeaReader[1];
  456. int ref;
  457. //for set mode param
  458. GpsPositionRecurrence recurrence;
  459. int min_interval;
  460. int preferred_accuracy;
  461. int preferred_time;
  462. int fix_frequency;
  463. //for supl server and port
  464. char suplhost[80];
  465. int suplport;
  466. //for callback
  467. GpsCallbacks callbacks;
  468. //AGpsCallbacks agps_callbacks;
  469. //GpsNiCallbacks ni_callbacks;
  470. //AGpsRilCallbacks agps_ril_callbacks;
  471. //GpsXtraCallbacks xtra_callbacks;
  472. //GpsGeofenceCallbacks geofence_callbacks;
  473. //for data conn,zhouxw add
  474. int connected;
  475. int type;
  476. int avaiable;
  477. int wifi_ok;
  478. int m_capabilities;
  479. int gps_flag;
  480. int gps_open;
  481. int started;
  482. int fix_stat;
  483. int logswitch;
  484. int workmode;
  485. //control sock
  486. int control[2];
  487. int asock[2];
  488. //for print debug,can remove
  489. int cmd_flag;
  490. int cpmode;
  491. int outtype;
  492. int lte_open;
  493. int lte_running;
  494. int realeph;
  495. int cmcc;
  496. int IdlOnCount;
  497. int IdlOffCount;
  498. int HeartCount;
  499. int waitHeartRsp;
  500. int keepIdleTime;
  501. int postlog;
  502. int watchdog;
  503. int imgmode;
  504. int sleepFlag;
  505. int sleepTimer;
  506. int stoptimer;
  507. int happenAssert;
  508. //it don't send sleep command in 5 minuter when laster cold-start
  509. int hotTestFlag;
  510. //gnss tool test
  511. int gnsstoolflag;
  512. //these is for power value
  513. TDevicepowerState powerState; // the device power state
  514. int powerErrorNum;
  515. //sem_t powersync; //power state sync
  516. //FILE* fFlashCfg;
  517. int fFlashCfg;
  518. //int fFlashCfg;
  519. //GNSS_REG_WR
  520. unsigned int wRegAddr;
  521. unsigned int wRegValue;
  522. unsigned int rRegAddr;
  523. unsigned int rRegValue;
  524. int screen_off; // SCREENOFF
  525. int release;
  526. //AGPS Timeout protection
  527. int agps_session;
  528. uint32 lastreftime;
  529. uint32 lastrefeph;
  530. int tsx_enable;
  531. int tsxIsdeliver;
  532. int etuMode;
  533. double tsx_temp; // TSXTEMP
  534. int cw_enable; // HW_CW
  535. int rftool_enable;
  536. int float_cn_enable;
  537. int baseband_mode;
  538. int phoneplatform; //0x1:feature phone
  539. int requestephmode;
  540. SCI_MUTEX_PTR dmamutex;
  541. int watchdogAssert;
  542. SCI_TIMER_PTR ge2sleeptimer;
  543. SCI_TIMER_PTR watchdogtimer;
  544. // for tsx
  545. TSX_TEMP_EXT_T tsx_temp_ext_get;
  546. TSX_TEMP_T tsx_temp_get;
  547. TSX_DATA_EXT_T apTsxData[TSX_DATA_GROUP_NUM_EXT];
  548. TsxData_EXT cpTsxData;
  549. SCI_MUTEX_PTR sv_info_mutex;
  550. SCI_MUTEX_PTR loc_info_mutex;
  551. GPS_NV_INFO_T gpsNvInfo;
  552. int init_type; /* for init by which module, defined in GNSS_INIT_TYPE */
  553. LowPowerGnss_T lpGnss;
  554. GnssModemBinInfo_T modemBinInfo; //gnss modem bin info
  555. MinilogCtx_T minilog_ctx;
  556. GnssCpInfo_T gnssCpInfo;
  557. char fix_flag;
  558. char is_nmea_log_to_pc;
  559. } GpsState;
  560. typedef enum
  561. {
  562. GNSS_MODE_UNKOWN = 0,
  563. GNSS_MODE_COLD_START,
  564. GNSS_MODE_WARM_START,
  565. GNSS_MODE_HOT_START,
  566. } GNSS_StartMode_e;
  567. typedef struct
  568. {
  569. GNSS_StartMode_e startMode;
  570. uint8 useAgnss;
  571. } MN_GPS_STARTMODE_AGNSS_T;
  572. typedef struct
  573. {
  574. SIGNAL_VARS
  575. MN_GPS_STARTMODE_AGNSS_T gps_startmode;
  576. } MN_GPS_STARTMODE_AGNSS_IND_T;
  577. #define MSB_SI 0
  578. #define MSB_NI 1
  579. #define MSA_SI 2
  580. #define MSA_NI 3
  581. #define GEO_MSB_SI 4
  582. #define GEO_MSB_NI 5
  583. #define GEO_MSA_SI 6
  584. #define GEO_MSA_NI 7
  585. #define PEROID_SI 8
  586. #define PEROID_NI 9
  587. #define CP_SI 10
  588. #define CP_NI 11
  589. typedef struct LLC
  590. {
  591. unsigned int weekNo; /*< week number (from beginning of current week cycle) */
  592. unsigned int second; /*< seconds (from beginning of current week no) */
  593. unsigned int secondFrac; /*< seconds fraction (from beginning of current second) units: 1ns */
  594. double lat;
  595. double lon;
  596. double hae;
  597. } WLLH_TYPE;
  598. typedef struct __TAgpsMsrElement_t
  599. {
  600. unsigned char systemid; //0-gps,1-glonass,2-beidou
  601. unsigned char satelliteID; // range: 0-63
  602. int cNo; // carrier noise ratio, range:(0..63)
  603. float doppler; // doppler, range:(-32768/5..32767/5)
  604. int wholeChips; // whole value of the code phase measurement, range:(0..1022)
  605. int fracChips; // fractional value of the code phase measurement, range:(0..1023),
  606. int mpathInd; // multipath indicator
  607. int pseuRangeRMSErr; // index, range:(0..63)
  608. #ifndef WIN32
  609. unsigned long long flags;
  610. long long received_gps_tow_ns;
  611. long long received_gps_tow_uncertainty_ns;
  612. #else
  613. unsigned _int64 flags;
  614. _int64 received_gps_tow_ns;
  615. _int64 received_gps_tow_uncertainty_ns;
  616. #endif
  617. double pseudorange_m;
  618. double pseudorange_uncertainty_m;
  619. float carrier_frequency_hz; // default L1
  620. unsigned int carrier_count;
  621. double carrier_phase;
  622. int bit_number; //Total bit number since midnight
  623. short time_from_last_bit_ms; // how many ms in one bit
  624. double elevation_deg;
  625. double elevation_uncertainty_deg;
  626. double azimuth_deg;
  627. double azimuth_uncertainty_deg;
  628. int used_in_fix;
  629. } TAgpsMsrElement_t;
  630. typedef struct __TAgpsMsrSetList_t
  631. {
  632. int gpsTOW; // unit:ms
  633. unsigned char listNums; // range:0-16
  634. TAgpsMsrElement_t msrElement[14]; // modify 16 to 14
  635. } TAgpsMsrSetList_t;
  636. typedef struct __TAgpsMsrElement_rawt
  637. {
  638. unsigned char systemid; //0-gps,1-glonass,2-beidou
  639. unsigned char satelliteID; // range: 0-63
  640. int cNo; // carrier noise ratio, range:(0..63)
  641. float doppler; // doppler, range:(-32768/5..32767/5)
  642. int wholeChips; // whole value of the code phase measurement, range:(0..1022)
  643. int fracChips; // fractional value of the code phase measurement, range:(0..1023),
  644. int mpathInd; // multipath indicator
  645. int pseuRangeRMSErr; // index, range:(0..63)
  646. } TAgpsMsrElement_raw_t;
  647. typedef struct __TAgpsMsrSetList_rawt
  648. {
  649. int gpsTOW; // unit:ms
  650. unsigned char listNums; // range:0-16
  651. TAgpsMsrElement_raw_t msrElement[14]; // todo change 14
  652. } TAgpsMsrSetList_raw_t;
  653. typedef struct
  654. {
  655. int bdsURAI;
  656. int weekNum; // add WN
  657. int bdsToe; /* 2^3 sec*/
  658. unsigned int bdsAPowerHalf; /*2^-19 meters^1/2*/
  659. unsigned int bdsE; /*2^-33 */
  660. int bdsW; /*2^-31 semi-circles */
  661. int bdsDeltaN; /*2^-43 semi-circles/sec */
  662. int bdsM0; /*2^-31 semi-circles */
  663. int bdsOmega0; /*2^-31 semi-circles */
  664. int bdsOmegaDot; /*2^-43 semi-circles/sec */
  665. int bdsI0; /*2^-31 semi-circles */
  666. int bdsIDot; /*2^-43 semi-circles/sec */
  667. int bdsCuc; /*2^-31 radians*/
  668. int bdsCus; /*2^-31 radians*/
  669. int bdsCrc; /*2^-6 meters*/
  670. int bdsCrs; /*2^-6 meters*/
  671. int bdsCic; /*2^-31 radians*/
  672. int bdsCis; /*2^-31 radians*/
  673. } * PBDS_EPHEMERIS, BDS_EPHEMERIS;
  674. typedef struct
  675. {
  676. int bdsToc; /* 2^3 seconds */
  677. int bdsA0; /* 2^-33 sec/sec */
  678. int bdsA1; /* 2^-50 sec/sec^2 */
  679. int bdsA2; /* 2^-66 seconds */
  680. int bdsTgd1; /* 10^-10 seconds */
  681. } * PBDS_CLOCK_EPHEMERIS, BDS_CLOCK_EPHEMERIS;
  682. extern GpsState _gps_state[1];
  683. //extern AgpsData_t agpsdata[1];
  684. //extern int sid_agps;
  685. extern char data_exist_flag;
  686. extern int gWriteFlag;
  687. extern int gDropCount;
  688. extern uint32 nmea_output_mode;
  689. extern GpsSvStatus SvState;
  690. #ifdef CONFIG_SOC_8850
  691. #define WEEK_MS_COUNT (7 * 24 * 60 * 60 * 1000)
  692. extern gpstime gps_idleon_time; // for 8850
  693. #endif
  694. /**---------------------------------------------------------------------------*
  695. ** Function Prototypes *
  696. **---------------------------------------------------------------------------*/
  697. void test_gps_mode(GpsState *s);
  698. void gps_state_start(GpsState *s);
  699. int gps_power_Statusync(int value);
  700. int gps_writeSerialData(GpsState *s, int len);
  701. void gps_sendData(int flag, const char *pBuf);
  702. void gps_setPowerState(int state);
  703. const char *gps_PowerStateName(int state);
  704. int gps_SendNotify(GpsState *s, int flag);
  705. void gps_dispatch(TCmdData_t *pPacket);
  706. void nmea_reader_parse(NmeaReader *r);
  707. int OsTimeSystemGet(gpstime *aGpsTime);
  708. int gps_wakeupDevice(GpsState *s);
  709. void gps_notiySleepDevice(GpsState *s);
  710. int gps_adingData(TCmdData_t *pPak);
  711. int recoverDevice(GpsState *pState);
  712. void createDump(GpsState *pState);
  713. void parseNmea(unsigned char *buf, int len);
  714. void nmea_parse_cp(unsigned char *buff, unsigned short lenth);
  715. int s2int(char *p, char len);
  716. void nmea_reader_addc(NmeaReader *r, int c);
  717. void gps_uart_dmastart(int uart_port);
  718. void gps_uart_dmaclose();
  719. void gps_send_assist_ge2(GpsState *s);
  720. void gps_send_eph_ge2(GpsState *s);
  721. void gps_saveEphToFlash(void);
  722. void gps_entersleep(void);
  723. void gps_send_sleep(uint32 state);
  724. //for tsx
  725. void update_tsx_param(void);
  726. int gps_getPowerState(void);
  727. void gps_set_testmode(uint32 mode);
  728. GpsSvStatus *Greeneye2_GetSvInfo(void);
  729. GpsLocation *Greeneye2_GetGpsLoc(void);
  730. int engpc_read_tsxtemp(char *pTsxTemp, int length);
  731. double greeneye2_getTcxoValue(void);
  732. void get_tsx_temp(unsigned char *buf, unsigned short length);
  733. void gps_handleSMDRequest(unsigned char *buf, unsigned short length);
  734. void gps_clear_ephdata(GpsState *s);
  735. void gps_clear_almdata(GpsState *s);
  736. int gps_serialPortRead(GpsState *pGPSState);
  737. int parse_assert_subtype_data(uint8 *input, uint8 *output, uint32 src_len, TGNSS_DataProcessor_t *stream_data);
  738. const char *gps_get_cp_ver_info(void);
  739. void gps_set_nmea_log_to_pc(bool isOn);
  740. void gps_nmeaReportTimerCb(uint32 wParam);
  741. void gps_manual_assert(void);
  742. int gps_read_eph_from_file(const uint16 *file_path, uint8 *buf, uint32 size);
  743. int gps_write_eph_to_file(const uint16 *file_path, uint8 *buf, uint32 size);
  744. void gps_state_stop(GpsState *s);
  745. GPS_ERR_E GreenEye2_updateTimestampOfNmea(OneNmeaMsg_T *pNmea);
  746. extern int GPSavEphRam2Flash(void);
  747. extern int GPSavEphRam2FlashAnyTime(void);
  748. void GreenEye2_send_nmea_packet();
  749. /**---------------------------------------------------------------------------*
  750. ** Compiler Flag *
  751. **---------------------------------------------------------------------------*/
  752. #ifdef __cplusplus
  753. }
  754. #endif /* __cplusplus */
  755. #endif //GREENEYE2_COMMON_H