gps_drv.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /******************************************************************************
  2. ** File Name: gps_drv.h *
  3. ** Author: Liangwen.Zhen *
  4. ** DATE: 07/26/2007 *
  5. ** Copyright: 2007 Spreadtrum, Incoporated. All Rights Reserved. *
  6. ** Description: This file defines the basic operation interfaces of GPS *
  7. ** *
  8. ******************************************************************************
  9. ******************************************************************************
  10. ** Edit History *
  11. ** ------------------------------------------------------------------------- *
  12. ** DATE NAME DESCRIPTION *
  13. ** 07/26/2007 Liangwen.Zhen/David.Jia Create. *
  14. ******************************************************************************/
  15. #ifndef _GPS_DRV_H_
  16. #define _GPS_DRV_H_
  17. /**---------------------------------------------------------------------------*
  18. ** Dependencies *
  19. **---------------------------------------------------------------------------*/
  20. #include "sci_types.h"
  21. /**---------------------------------------------------------------------------*
  22. ** Debugging Flag *
  23. **---------------------------------------------------------------------------*/
  24. /**---------------------------------------------------------------------------*
  25. ** Compiler Flag *
  26. **---------------------------------------------------------------------------*/
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /**---------------------------------------------------------------------------*
  31. ** Macro Definition *
  32. **---------------------------------------------------------------------------*/
  33. #define GPS_CHN_CNT_MAX 32
  34. /**---------------------------------------------------------------------------*
  35. ** Enum Definition *
  36. **---------------------------------------------------------------------------*/
  37. #if defined(GPS_CHIP_VER_GREENEYE2)
  38. #include "gps_interface.h"
  39. #define GPS_COM 1 //uart port
  40. #if defined(HW_ALPHA_CUSTOMER)
  41. #define GPIO_GPS_CHIP_EN 19
  42. #else
  43. #define GPIO_GPS_CHIP_EN 68
  44. #endif
  45. #endif
  46. typedef enum
  47. {
  48. GPS_ERR_NONE = 0x00,
  49. GPS_ERR_PARAM,
  50. GPS_ERR_NO_MODULE,
  51. GPS_ERR_MAX
  52. } GPS_ERR_E;
  53. #ifdef GPS_CHIP_VER_GREENEYE2
  54. typedef enum
  55. {
  56. GPS_MODE_BD,
  57. GPS_MODE_GLONASS,
  58. GPS_MODE_FDL,
  59. GPS_MODE_MAX
  60. } GPS_MODE_E;
  61. #else
  62. typedef enum
  63. {
  64. GPS_MODE_NORMAL = 0x00,
  65. GPS_MODE_AGPS,
  66. GPS_MODE_TEST_NMEA,
  67. #if defined(GPS_CHIP_VER_GREENEYE2)
  68. GPS_MODE_BD,
  69. GPS_MODE_GLONASS,
  70. #endif
  71. GPS_MODE_MAX
  72. } GPS_MODE_E;
  73. #endif
  74. typedef enum
  75. {
  76. GPS_STATUS_NOT_INIT = 0x00,
  77. GPS_STATUS_INIT,
  78. GPS_STATUS_OPEN,
  79. GPS_STATUS_SLEEP,
  80. GPS_STATUS_LOST,
  81. GPS_STATUS_CLOSE,
  82. GPS_STATUS_IDLEOFF,
  83. #if defined(GPS_CHIP_VER_GREENEYE2)
  84. GPS_STATUS_POWEROFF,
  85. #endif
  86. GPS_STATUS_MAX
  87. } GPS_STATUS_E;
  88. #define DBG_8850 8850
  89. /**---------------------------------------------------------------------------*
  90. ** Data Structure Definition *
  91. **---------------------------------------------------------------------------*/
  92. /**
  93. typedef struct gps_nv_info_tag
  94. {
  95. uint8 engine_sn[24];
  96. uint8 map_version[4];
  97. uint8 activate_code[16];
  98. }GPS_NV_INFO_T;
  99. **/
  100. //copy from MS_Code\common\nv_parameters\wcn\h\GPS_CONFIGURE.h
  101. typedef struct
  102. {
  103. uint8 sn[24]; /* sn */
  104. uint8 cap_config[4]; /* cap_config, bit0 of capabilities[3] - support SMD or not */
  105. uint8 ac_code[16]; /* ac_code */
  106. uint8 img_string[16]; /* img_string */
  107. uint8 lte_enable; /* lte enable */
  108. uint8 cp_mode; /* cp mode */
  109. uint8 uartName[22]; /* uartName */
  110. uint8 uartSpeed[32]; /* uartSpeed */
  111. uint8 sttyName[30]; /* sttyName */
  112. uint8 platform; /* cp platform */
  113. } GPS_NV_INFO_T;
  114. typedef struct gps_validation_cipher_tag
  115. {
  116. uint32 high_cipher;
  117. uint32 low_cipher;
  118. } GPS_VALIDATION_CIPHER_T;
  119. typedef struct gps_channel_info_tag
  120. {
  121. uint16 sat_id;
  122. uint16 snr;
  123. uint16 elevation;
  124. uint16 azimuth;
  125. } GPS_CHN_INFO_T;
  126. typedef struct gps_info_tag
  127. {
  128. BOOLEAN is_hw_work;
  129. BOOLEAN is_position_fix;
  130. uint16 cnt_of_sat_in_view;
  131. uint16 cnt_of_sat_fix;
  132. uint16 north_or_south; // 'N': North, 'S': South; Others: invalid
  133. uint16 latitude_high; // ddmm
  134. uint16 latitude_low; // .mmmm
  135. uint16 east_or_west; // 'E': East; 'W': West: Others: invalid
  136. uint16 longitude_high; // ddmm
  137. uint16 longitude_low; // .mmmm
  138. uint16 cnt_of_chn_valid;
  139. GPS_CHN_INFO_T gps_chn[GPS_CHN_CNT_MAX];
  140. } GPS_INFO_T, *GPS_INFO_T_PTR;
  141. #if defined(GPS_CHIP_VER_GREENEYE2)
  142. /** Maximum number of SVs for gps_sv_status_callback(). */
  143. #define GPS_MAX_SVS 256
  144. /** Represents SV information. */
  145. typedef struct
  146. {
  147. /** set to sizeof(GpsSvInfo) */
  148. uint32 size;
  149. /** Pseudo-random number for the SV. */
  150. int prn;
  151. /** Signal to noise ratio. */
  152. float snr;
  153. /** Elevation of SV in degrees. */
  154. float elevation;
  155. /** Azimuth of SV in degrees. */
  156. float azimuth;
  157. } GpsSvInfo;
  158. /** Represents SV status. */
  159. typedef struct
  160. {
  161. /** set to sizeof(GpsSvStatus) */
  162. uint32 size;
  163. /** Number of SVs currently visible. */
  164. int num_svs;
  165. /** Contains an array of SV information. */
  166. GpsSvInfo sv_list[GPS_MAX_SVS];
  167. /** Represents a bit mask indicating which SVs
  168. * have ephemeris data.
  169. */
  170. uint32 ephemeris_mask[8];
  171. /** Represents a bit mask indicating which SVs
  172. * have almanac data.
  173. */
  174. uint32 almanac_mask[8];
  175. /**
  176. * Represents a bit mask indicating which SVs
  177. * were used for computing the most recent position fix.
  178. */
  179. uint32 used_in_fix_mask[8];
  180. } GpsSvStatus;
  181. typedef struct gps_operations_tag
  182. {
  183. GPS_ERR_E(*gps_init)
  184. (void);
  185. GPS_ERR_E(*gps_open)
  186. (BLOCK_ID sender_id);
  187. GPS_ERR_E(*gps_idleoff)
  188. (void);
  189. GPS_ERR_E(*gps_close)
  190. (void);
  191. uint32 (*gps_readdata)(uint8 *read_buf_ptr, uint32 byte_to_read);
  192. uint32 (*gps_writedata)(uint8 *write_buf_ptr, uint32 byte_to_write);
  193. BOOLEAN(*gps_identify)
  194. (void);
  195. GPS_ERR_E(*gps_setrestart)
  196. (uint32 mode);
  197. GPS_ERR_E(*gps_getnmeadata)
  198. (uint32 mode, uint8 *buff);
  199. GPS_ERR_E(*gps_setoutputmode)
  200. (uint32 mode, uint32 time_interval, BLOCK_ID sender_id);
  201. GPS_ERR_E(*gps_download)
  202. (void);
  203. GPS_ERR_E(*gps_poweroff)
  204. (void);
  205. uint32 (*gps_readinfodata)(char **read_buf_ptr, uint32 byte_to_read);
  206. GPS_ERR_E(*gps_writeagpsdata)
  207. (char *agps_data, uint32 length);
  208. GPS_ERR_E(*gps_debuglogenable)
  209. (uint8 status);
  210. GPS_ERR_E(*gps_nmealogenable)
  211. (uint8 status);
  212. GpsSvStatus *(*gps_getsvinfo)(void);
  213. GPS_ERR_E(*gps_testmodeenable)
  214. (uint8 status);
  215. GPS_ERR_E(*gps_setrftestmode)
  216. (GPS_RF_TEST_MODE_E rf_mode);
  217. GPS_ERR_E(*gps_sendephdata)
  218. (void);
  219. GPS_ERR_E(*gps_clearephdata)
  220. (void);
  221. GPS_ERR_E(*gps_sendwatchdog)
  222. (void);
  223. GPS_ERR_E(*gps_clearalmdata)
  224. (void);
  225. GPS_ERR_E(*gps_downloadfdl)
  226. (void);
  227. GPS_ERR_E(*gps_setassert)
  228. (uint8 assertmode);
  229. GPS_ERR_E(*gps_entersleep)
  230. (void);
  231. GPS_ERR_E(*gps_handleSmdIndMsg)
  232. (void);
  233. } GPS_OPERATIONS_T;
  234. #else
  235. typedef struct gps_operations_tag
  236. {
  237. GPS_ERR_E(*gps_init)
  238. (void);
  239. GPS_ERR_E(*gps_open)
  240. (GPS_MODE_E mode);
  241. GPS_ERR_E(*gps_idleoff)
  242. (void);
  243. GPS_ERR_E(*gps_close)
  244. (void);
  245. GPS_ERR_E(*gps_sleep)
  246. (BOOLEAN is_sleep);
  247. GPS_ERR_E(*gps_reflash)
  248. (void);
  249. uint32 (*gps_readdata)(uint8 *read_buf_ptr, uint32 byte_to_read);
  250. uint32 (*gps_writedata)(uint8 *write_buf_ptr, uint32 byte_to_write);
  251. BOOLEAN(*gps_identify)
  252. (void);
  253. uint32 (*gps_test)(void *ptr, uint32 param);
  254. } GPS_OPERATIONS_T;
  255. #endif
  256. /*****************************************************************************/
  257. // Description: This function is used to set GPS module status
  258. // Author: Liangwen.Zhen
  259. // Note:
  260. /*****************************************************************************/
  261. PUBLIC void _GPS_SetStatus(GPS_STATUS_E status);
  262. /**---------------------------------------------------------------------------*
  263. ** Local Function Prototypes *
  264. **---------------------------------------------------------------------------*/
  265. /*****************************************************************************/
  266. // Description: This function is used to get GPS status
  267. // Author: Liangwen.Zhen
  268. // Note:
  269. /*****************************************************************************/
  270. PUBLIC GPS_STATUS_E GPS_GetStatus(void);
  271. /*****************************************************************************/
  272. // Description: This function is used to init GPS mode and global variable
  273. // Author: Liangwen.Zhen
  274. // Note:
  275. /*****************************************************************************/
  276. PUBLIC GPS_ERR_E GPS_Init(void);
  277. /*****************************************************************************/
  278. // Description: This function is used to open GPS module by the special mode
  279. // Author: Liangwen.Zhen
  280. // Note:
  281. // input: GPS_MODE_E
  282. // Output: GPS_ERR_E
  283. /*****************************************************************************/
  284. #if defined(GPS_CHIP_VER_GREENEYE2)
  285. PUBLIC GPS_ERR_E GPS_Open(void);
  286. #else
  287. PUBLIC GPS_ERR_E GPS_Open(GPS_MODE_E mode);
  288. #endif
  289. /*****************************************************************************/
  290. // Description: This function is used to GPS_IdleOff module by the special mode
  291. // Author: Liangwen.Zhen
  292. // Note:
  293. // input: GPS_MODE_E
  294. // Output: GPS_ERR_E
  295. /*****************************************************************************/
  296. PUBLIC GPS_ERR_E GPS_IdleOff(void);
  297. /*****************************************************************************/
  298. // Description: This function is used to Close GPS module
  299. // Author: Liangwen.Zhen
  300. // Note:
  301. /*****************************************************************************/
  302. PUBLIC GPS_ERR_E GPS_Close(void);
  303. /*****************************************************************************/
  304. // Description: This function is used to Close GPS module
  305. // Author: Liangwen.Zhen
  306. // Note:
  307. /*****************************************************************************/
  308. PUBLIC GPS_ERR_E GPS_EnterSleep(BOOLEAN is_sleep);
  309. /*****************************************************************************/
  310. // Description: This function is used to read data from GPS module
  311. // Author: Liangwen.Zhen
  312. // Note:
  313. /*****************************************************************************/
  314. PUBLIC uint32 GPS_ReadData(uint8 *read_buf_ptr, uint32 byte_to_read);
  315. /*****************************************************************************/
  316. // Description: This function is used to write data to GPS module
  317. // Author: Liangwen.Zhen
  318. // Note:
  319. /*****************************************************************************/
  320. PUBLIC uint32 GPS_WriteData(uint8 *write_buf_ptr, uint32 byte_to_write);
  321. /*****************************************************************************/
  322. // Description: This function is used to test GPS module
  323. // Author: Liangwen.Zhen
  324. // Note:
  325. /*****************************************************************************/
  326. PUBLIC GPS_INFO_T_PTR GPS_GetGpsInfo(void);
  327. /*****************************************************************************/
  328. // Description: This function is used to test GPS mode
  329. // Author: Liangwen.Zhen
  330. // Note:
  331. /*****************************************************************************/
  332. PUBLIC uint32 GPS_Test(void *ptr, uint32 param);
  333. /*****************************************************************************/
  334. // Description: This function is used to get validation cipher from DSP
  335. // Author: Liangwen.Zhen
  336. // Note:
  337. /*****************************************************************************/
  338. PUBLIC uint32 GPS_GetValidationCipher(
  339. uint32 input_serial,
  340. GPS_VALIDATION_CIPHER_T *output_validation_cipher_ptr);
  341. #if defined(GPS_CHIP_VER_GREENEYE2)
  342. /*****************************************************************************/
  343. // Description: GreenEye2_GetNmeaData
  344. // Author:
  345. // Note:
  346. /*****************************************************************************/
  347. GPS_ERR_E GPS_GetNmeaData(uint32 mode, uint8 *buff);
  348. /*****************************************************************************/
  349. // Description: GreenEye2_SetOutputMode
  350. // Author:
  351. // Note:
  352. /*****************************************************************************/
  353. GPS_ERR_E GPS_SetOutputMode(uint32 mode, uint32 time_interval, BLOCK_ID sender_id);
  354. /*****************************************************************************/
  355. // Description: GPS_ReadInfoData
  356. // Author:
  357. // Note:
  358. /*****************************************************************************/
  359. PUBLIC uint32 GPS_ReadInfoData(char **read_buf_ptr, uint32 byte_to_read);
  360. /*****************************************************************************/
  361. // Description: GPS_PowerOff
  362. // Author:
  363. // Note:
  364. /*****************************************************************************/
  365. PUBLIC GPS_ERR_E GPS_PowerOff(void);
  366. /*****************************************************************************/
  367. // Description: GPS_Init_Greeneye2
  368. // Author:
  369. // Note:
  370. /*****************************************************************************/
  371. PUBLIC GPS_ERR_E GPS_Init_Greeneye2(void);
  372. /*****************************************************************************/
  373. // Description: GPS_Download
  374. // Author:
  375. // Note:
  376. /*****************************************************************************/
  377. PUBLIC GPS_ERR_E GPS_Download(void);
  378. /*****************************************************************************/
  379. // Description: enable nmea log output to diag
  380. // Author:
  381. // Note:
  382. /*****************************************************************************/
  383. PUBLIC GPS_ERR_E GPS_NmeaLog_Enable(uint8 status);
  384. /*****************************************************************************/
  385. // Description: Enable debug log output to diag
  386. // Author:
  387. // Note:
  388. /*****************************************************************************/
  389. PUBLIC GPS_ERR_E GPS_DebugLog_Enable(uint8 status);
  390. /*****************************************************************************/
  391. // Description: GPS_SetRestart
  392. // Author:
  393. // Note:
  394. /*****************************************************************************/
  395. PUBLIC GPS_ERR_E GPS_SetRestart(uint32 mode);
  396. /*****************************************************************************/
  397. // Description: get gps fix satellites
  398. // Author:
  399. // Note:
  400. /*****************************************************************************/
  401. PUBLIC uint8 GPS_Get_FixSatellites();
  402. /*****************************************************************************/
  403. // Description: get gps fix status
  404. // Author:
  405. // Note:
  406. /*****************************************************************************/
  407. PUBLIC uint8 GPS_Get_FixStatus();
  408. /*****************************************************************************/
  409. // Description: GPS_Send_EphData
  410. // Author:
  411. // Note:
  412. /*****************************************************************************/
  413. PUBLIC GPS_ERR_E GPS_Send_EphData(void);
  414. /*****************************************************************************/
  415. // Description: GPS_Send_Watchdog
  416. // Author:
  417. // Note:
  418. /*****************************************************************************/
  419. PUBLIC GPS_ERR_E GPS_Send_Watchdog(void);
  420. /*****************************************************************************/
  421. // Description: GPS_Download_Fdl
  422. // Author:
  423. // Note:
  424. /*****************************************************************************/
  425. PUBLIC GPS_ERR_E GPS_Download_Fdl(void);
  426. /*****************************************************************************/
  427. // Description: GPS_Set_Assert
  428. // Author:
  429. // Note:
  430. /*****************************************************************************/
  431. PUBLIC GPS_ERR_E GPS_Set_Assert(uint8 assertmode);
  432. /*****************************************************************************/
  433. // Description: GPS_Enter_Sleep
  434. // Author:
  435. // Note:
  436. /*****************************************************************************/
  437. PUBLIC GPS_ERR_E GPS_Enter_Sleep(void);
  438. /*****************************************************************************/
  439. // Description: get gps svinfo
  440. // Author:
  441. // Note:
  442. /*****************************************************************************/
  443. PUBLIC void GPS_Get_Svinfo(GpsSvStatus *svinfo);
  444. /*****************************************************************************/
  445. // Description: enable test mode
  446. // Author:
  447. // Note:
  448. /*****************************************************************************/
  449. PUBLIC GPS_ERR_E GPS_TestMode_Enable(uint8 status);
  450. /*****************************************************************************/
  451. // Description: GPS_Reset_Request
  452. // Author:
  453. // Note:
  454. /*****************************************************************************/
  455. void GPS_Reset_Request(uint8 mode);
  456. /*****************************************************************************/
  457. // Description: GPS_Clear_EphData
  458. // Author:
  459. // Note:
  460. /*****************************************************************************/
  461. PUBLIC GPS_ERR_E GPS_Clear_EphData();
  462. /*****************************************************************************/
  463. // Description: GPS_Clear_AlmData
  464. // Author:
  465. // Note:
  466. /*****************************************************************************/
  467. PUBLIC GPS_ERR_E GPS_Clear_AlmData();
  468. /*****************************************************************************/
  469. // Description: GPS_Set_RFTestMode
  470. // Author:
  471. // Note:
  472. /*****************************************************************************/
  473. PUBLIC GPS_ERR_E GPS_Set_RFTestMode(GPS_RF_TEST_MODE_E rf_mode);
  474. /*****************************************************************************/
  475. // Description :
  476. // Global resource dependence :
  477. // Auhor:
  478. // Note:
  479. /*****************************************************************************/
  480. void GPSTEST_SendDownloadReq(
  481. MN_DUAL_SYS_E dual_sys);
  482. /*****************************************************************************/
  483. // Description :
  484. // Global resource dependence :
  485. // Auhor:
  486. // Note:
  487. /*****************************************************************************/
  488. void GPSTEST_SendInitReq(
  489. MN_DUAL_SYS_E dual_sys);
  490. /*****************************************************************************/
  491. // Description :
  492. // Global resource dependence :
  493. // Auhor:
  494. // Note:
  495. /*****************************************************************************/
  496. void GPSTEST_SendStartReq(
  497. MN_DUAL_SYS_E dual_sys,
  498. uint8 type,
  499. uint32 start_mode);
  500. /*****************************************************************************/
  501. // Description :
  502. // Global resource dependence :
  503. // Author:
  504. // Note:
  505. /*****************************************************************************/
  506. void GPSTEST_SendStopReq(
  507. MN_DUAL_SYS_E dual_sys);
  508. /*****************************************************************************/
  509. // Description :
  510. // Global resource dependence :
  511. // Author:
  512. // Note:
  513. /*****************************************************************************/
  514. void GPSTEST_SendWatchdogReq(
  515. MN_DUAL_SYS_E dual_sys);
  516. /**************************************************************************
  517. * Function : gnss_setWorkmode
  518. * Description : init the gnss work mode
  519. * Parameters : char mode: cp work mode like GNSS_GLONASS_WORKMODE
  520. * Retur : -1 - fail, others succ
  521. **************************************************************************/
  522. PUBLIC int gnss_setWorkmode(unsigned char mode);
  523. /*************************************************************************
  524. * Function : gnss_getcpmode
  525. * Description : get the gnss work mode
  526. * Parameters :
  527. * Return : gnss work mode
  528. **************************************************************************/
  529. PUBLIC int gnss_getcpmode();
  530. /*************************************************************************
  531. * Function : MN_GPS_STARTMODE_AGNSS
  532. * Description : get the gnss work mode
  533. * Parameters :
  534. * Return : gnss work mode
  535. **************************************************************************/
  536. void MN_GPS_STARTMODE_AGNSS();
  537. #endif
  538. /**---------------------------------------------------------------------------*
  539. ** Compiler Flag *
  540. **---------------------------------------------------------------------------*/
  541. #ifdef __cplusplus
  542. }
  543. #endif // End of gsp_drv.h
  544. #endif // end _GPS_DRV_H_