Files
QDAC-firmware/libraries/zf_device/zf_device_gps_tau1201.h

121 lines
6.0 KiB
C
Raw Normal View History

2023-12-11 21:45:06 +08:00
/*********************************************************************************************************************
* CH32V307VCT6 Opensourec Library CH32V307VCT6 SDK
* Copyright (c) 2022 SEEKFREE
*
* CH32V307VCT6
*
* CH32V307VCT6
* GPLGNU General Public License GNU通用公共许可证
* GPL 3 GPL3.0/
*
*
*
* GPL
*
* GPL
* <https://www.gnu.org/licenses/>
*
*
* 使 GPL3.0
* libraries/doc GPL3_permission_statement.txt
* libraries LICENSE
* 使
*
* isr
*
* libraries/doc version
* MounRiver Studio V1.8.1
* CH32V307VCT6
* https://seekfree.taobao.com/
*
*
*
* 2022-08-10 Teternal first version
* 2022-09-21 SeekFree 使
********************************************************************************************************************/
/*********************************************************************************************************************
* 线
* ------------------------------------
*
* RX zf_device_gps_tau1201.h GPS_TAU1201_RX
* TX zf_device_gps_tau1201.h GPS_TAU1201_TX
* VCC 3.3V电源
* GND
* ------------------------------------
********************************************************************************************************************/
#ifndef _zf_device_gps_tau1201_h_
#define _zf_device_gps_tau1201_h_
#include "zf_common_typedef.h"
//--------------------------------------------------------------------------------------------------
//引脚配置
//--------------------------------------------------------------------------------------------------
#define GPS_TAU1201_UART (UART_8)
#define GPS_TAU1201_RX (UART8_MAP3_TX_E14) // GPS RX引脚连接到单片机此
#define GPS_TAU1201_TX (UART8_MAP3_RX_E15) // GPS TX串口引脚
#define ANGLE_TO_RAD(x) ((x) * PI / 180.0) // 角度转换为弧度
#define RAD_TO_ANGLE(x) ((x) * 180.0 / PI) // 弧度转换为角度
#define PI (3.1415926535898)
typedef struct
{
uint16 year;
uint8 month;
uint8 day;
uint8 hour;
uint8 minute;
uint8 second;
}gps_time_struct;
typedef struct
{
gps_time_struct time; // 时间
uint8 state; // 有效状态 1定位有效 0定位无效
uint16 latitude_degree; // 度
uint16 latitude_cent; // 分
uint16 latitude_second; // 秒
uint16 longitude_degree; // 度
uint16 longitude_cent; // 分
uint16 longitude_second; // 秒
double latitude; // 经度
double longitude; // 纬度
int8 ns; // 纬度半球 N北半球或 S南半球
int8 ew; // 经度半球 E东经或 W西经
float speed; // 速度(公里/每小时)
float direction; // 地面航向000.0~359.9 度,以真北方为参考基准)
// 下面两个个信息从GNGGA语句中获取
uint8 satellite_used; // 用于定位的卫星数量
float height; // 高度
}gps_info_struct;
typedef enum
{
GPS_STATE_RECEIVING, // 正在接收数据
GPS_STATE_RECEIVED, // 数据接收完成
GPS_STATE_PARSING, // 正在解析
}gps_state_enum;
extern gps_info_struct gps_tau1201;
extern uint8 gps_tau1201_flag;
double get_two_points_distance (double lat1, double lng1, double lat2, double lng2);
double get_two_points_azimuth (double lat1, double lon1, double lat2, double lon2);
uint8 gps_data_parse (void);
void gps_uart_callback (void);
void gps_init (void);
#endif