126 lines
3.6 KiB
C
126 lines
3.6 KiB
C
|
/*------------------------------------------------------------
|
|||
|
// Copyright (c) 2022 SmartLogic.
|
|||
|
// ALL RIGHTS RESERVED
|
|||
|
// -----------------------------------------------------------------
|
|||
|
// Filename : stc_drv.c
|
|||
|
// Author : weihua.li
|
|||
|
// Created On : 2022-11-23
|
|||
|
// Last Modified :
|
|||
|
// -----------------------------------------------------------------
|
|||
|
// Description:
|
|||
|
//
|
|||
|
//
|
|||
|
// ----------------------------------------------------------------*/
|
|||
|
|
|||
|
#ifndef __LC98S_DRV_H__
|
|||
|
#define __LC98S_DRV_H__
|
|||
|
|
|||
|
#define NUMCHN 20
|
|||
|
#define GPS_TX_BUF_SIZE 256
|
|||
|
#define GPS_RX_BUF_SIZE 1024
|
|||
|
#define GPS_SEM_NUM 13
|
|||
|
#define HALF_BUFSIZE 511
|
|||
|
#define MY_IPCKEY 0x10005500
|
|||
|
|
|||
|
#define MIN(x,y) ((x)<(y)?(x):(y))
|
|||
|
#define MAX(x,y) ((x)>(y)?(x):(y))
|
|||
|
|
|||
|
#define GPS_SECONDS(tow,wnum) (604800*(wnum) + (tow))
|
|||
|
#define MOD_2N(x,y) ((x) & (y-1))
|
|||
|
|
|||
|
|
|||
|
#define GPS_FIX_OK 0x03
|
|||
|
#define NAV_ALMANACH 0x04
|
|||
|
|
|||
|
/* arg for semctl system calls. */
|
|||
|
union semun {
|
|||
|
int val; /* value for SETVAL */
|
|||
|
struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */
|
|||
|
unsigned short *array; /* array for GETALL & SETALL */
|
|||
|
struct seminfo *__buf; /* buffer for IPC_INFO */
|
|||
|
};
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
int32_t latitude; /*degree 1e-7*/
|
|||
|
int32_t longitude;/*degree 1e-7*/
|
|||
|
int32_t altitude; /*millimeter*/
|
|||
|
uint8_t gps_fix;
|
|||
|
uint8_t fix_flag;
|
|||
|
uint32_t time_of_week;
|
|||
|
uint8_t valid_flag;
|
|||
|
int8_t leap_sec;
|
|||
|
uint16_t week_number;
|
|||
|
uint8_t num_ch;
|
|||
|
int16_t cab_dly; /*cable delay time,uint:ns*/
|
|||
|
uint32_t pulse_width; /*Length of time pulse*/
|
|||
|
int8_t pps_status; /*PPS: >0,postive; =0,no;<0, negative*/
|
|||
|
uint8_t ant_state;
|
|||
|
uint8_t sw_version[30];
|
|||
|
uint8_t hw_version[10];
|
|||
|
uint8_t sta_id[NUMCHN]; /*satellite ID*/
|
|||
|
uint8_t cno[NUMCHN]; /*Carrier to Noise Ratio (Signal Strength)*/
|
|||
|
uint8_t tracking_num;
|
|||
|
uint8_t visable_num;
|
|||
|
uint8_t sig_over_high;
|
|||
|
uint8_t lock_state; /*1: gps lock 0: gps unlock*/
|
|||
|
|
|||
|
}drv_gps_msg_s;
|
|||
|
|
|||
|
/********************************************************************/
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
uint8_t recv_buf[GPS_RX_BUF_SIZE];
|
|||
|
/*union
|
|||
|
{
|
|||
|
uint32_t whole;
|
|||
|
struct
|
|||
|
{
|
|||
|
uint16_t recv_ptr; //接收指针
|
|||
|
uint16_t deal_ptr; //处理指针
|
|||
|
}
|
|||
|
}*/
|
|||
|
uint16_t recv_ptr; /*接收指针*/
|
|||
|
uint16_t deal_ptr; /*处理指针*/
|
|||
|
uint16_t recv_cnt; /*最新接收到的消息长<E681AF><E995BF>?*/
|
|||
|
uint16_t deal_cnt; /*未处理消息长<E681AF><E995BF>?*/
|
|||
|
int32_t send_sem;
|
|||
|
uint8_t *send_buf_ptr;
|
|||
|
uint16_t send_cnt; /*待发送消息长<E681AF><E995BF>?*/
|
|||
|
uint16_t frame_flag; //帧头
|
|||
|
}gps_uart_s;
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
int32_t latitude; //纬度 单位:度/1e-7
|
|||
|
int32_t longitude; //经度 单位:度/1e-7
|
|||
|
int32_t altitude; //高度 单位:毫<EFBC9A><E6AFAB>?
|
|||
|
}location_info_s;
|
|||
|
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
uint8_t lock_flag; /* GPS Fixed ok */
|
|||
|
uint8_t leap_valid; /* leap second valid */
|
|||
|
uint8_t view_sats; /* Satellites in view */
|
|||
|
uint8_t track_sats; /* Satellites under tracking */
|
|||
|
uint8_t survey_in; /*0 not in Survey-in mode*/
|
|||
|
uint8_t alma_complete; /* 0 Calendar not complete */
|
|||
|
uint8_t resv[2]; /* resv*/
|
|||
|
float sig_level[12]; /* signal level of satellites */
|
|||
|
}tracking_info_s;
|
|||
|
|
|||
|
int32_t drv_tfu_gps_init(void);
|
|||
|
void drv_gps_recv_task(void);
|
|||
|
int32_t init_clock_module(void);
|
|||
|
int32_t get_receiver_fix_status();
|
|||
|
int32_t get_src_time(time_t* time_ptr);
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
#if __cplusplus
|
|||
|
}
|
|||
|
#endif
|
|||
|
#endif
|
|||
|
|
|||
|
#endif
|
|||
|
/**********************************************************************/
|