px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
px_nmea.h
1#ifndef __PX_NMEA_H__
2#define __PX_NMEA_H__
3/* =============================================================================
4 ____ ___ ____ ___ _ _ ___ __ __ ___ __ __ TM
5 | _ \ |_ _| / ___| / _ \ | \ | | / _ \ | \/ | |_ _| \ \/ /
6 | |_) | | | | | | | | | | \| | | | | | | |\/| | | | \ /
7 | __/ | | | |___ | |_| | | |\ | | |_| | | | | | | | / \
8 |_| |___| \____| \___/ |_| \_| \___/ |_| |_| |___| /_/\_\
9
10 Copyright (c) 2010 Pieter Conradie <https://piconomix.com>
11
12 License: MIT
13 https://github.com/piconomix/px-fwlib/blob/master/LICENSE.md
14
15 Title: px_nmea.h : NMEA parser
16 Author(s): Pieter Conradie
17 Creation Date: 2010-05-28
18
19============================================================================= */
20
21/**
22 * @ingroup COMMS
23 * @defgroup PX_NMEA px_nmea.h : NMEA parser
24 *
25 * GPS NMEA protocol parser.
26 *
27 * File(s):
28 * - comms/inc/px_nmea.h
29 * - comms/src/px_nmea.c
30 *
31 * @see http://en.wikipedia.org/wiki/NMEA_0183
32 *
33 * @{
34 */
35
36/* _____STANDARD INCLUDES____________________________________________________ */
37
38/* _____PROJECT INCLUDES_____________________________________________________ */
39#include "px_defs.h"
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44/* _____DEFINITIONS__________________________________________________________ */
45// NMEA output strings
46#define PX_NMEA_GGA_STR "GGA" ///< Time, position and fix type data
47#define PX_NMEA_GLL_STR "GLL" ///< Latitude, longitude, UTC time of position fix and status
48#define PX_NMEA_GSA_STR "GSA" ///< GPS receiver operating mode, satellites used in the position solution and DOP values
49#define PX_NMEA_GSV_STR "GSV" ///< The number of GPS satellites in view, satellite ID numbers, elevation, azimuth, and SNR values
50#define PX_NMEA_MSS_STR "MSS" ///< Signal-to-noise ratio, signal strength, frequency, and bit rate from a radio-beacon receiver
51#define PX_NMEA_RMC_STR "RMC" ///< Time, date, position, course and speed data
52#define PX_NMEA_VTG_STR "VTG" ///< Course and speed information relative to the ground
53#define PX_NMEA_ZDA_STR "ZDA" ///< Date and time
54
55/* _____TYPE DEFINITIONS_____________________________________________________ */
56/**
57 * Definition for a pointer to a function that will be called to
58 * send a character.
59 */
60typedef void (*px_nmea_tx_byte_t)(uint8_t data);
61
62/**
63 * Definition for a pointer to a function that when a valid NMEA string is
64 * received.
65 */
66typedef void (*px_nmea_on_valid_str_t)(const char * data);
67
68/**
69 * Definition for a pointer to a function that will be called when GPS data
70 * is valid.
71 */
72typedef void (*px_nmea_on_valid_gps_data_t)(void);
73
74/// Parsed time, position, quality data
75typedef struct
76{
77 uint32_t utc_time;
78 uint16_t utc_time_fraction;
79 uint8_t delay_from_PPS;
80 int16_t latitude;
81 uint16_t latitude_fraction;
82 int16_t longitude;
83 uint16_t longitude_fraction;
84 int16_t altitude;
85 uint8_t altitude_fraction;
86 uint16_t heading;
87 uint8_t heading_fraction;
88 uint8_t speed;
89 uint8_t speed_fraction;
90 uint8_t sattelites_used;
91 uint8_t hdop;
92 uint8_t hdop_fraction;
93 bool gga_valid_flag;
94 bool vtg_valid_flag;
96
97/* _____GLOBAL VARIABLES_____________________________________________________ */
98px_nmea_data_t px_nmea_data;
99
100/* _____GLOBAL FUNCTION DECLARATIONS_________________________________________ */
101/**
102 * Initialise NMEA parser module
103 *
104 * @param tx_byte Pointer to a function that will be called to
105 * transmit a byte.
106 * @param on_valid_str Pointer to a function that will be called when a
107 * valid NMEA string has been received.
108 * @param on_valid_gps_data Pointer to a function that will be called when the
109 * data structure has been completely polulated with
110 * valid data.
111 */
113 px_nmea_on_valid_str_t on_valid_str,
114 px_nmea_on_valid_gps_data_t on_valid_gps_data);
115
116/**
117 * Function handler that is fed all raw received data.
118 *
119 * @param[in] data received 8-bit data
120 *
121 */
122void px_nmea_on_rx_byte(uint8_t data);
123
124/**
125 * Function that is called to send an NMEA frame with the checksum appended.
126 *
127 * @param frame Pointer to zero terminated string.
128 */
129void px_nmea_tx_frame(char * frame);
130
131/* _____MACROS_______________________________________________________________ */
132
133#ifdef __cplusplus
134}
135#endif
136
137/// @}
138#endif
void(* px_nmea_on_valid_gps_data_t)(void)
Definition for a pointer to a function that will be called when GPS data is valid.
Definition: px_nmea.h:72
void(* px_nmea_on_valid_str_t)(const char *data)
Definition for a pointer to a function that when a valid NMEA string is received.
Definition: px_nmea.h:66
void(* px_nmea_tx_byte_t)(uint8_t data)
Definition for a pointer to a function that will be called to send a character.
Definition: px_nmea.h:60
void px_nmea_tx_frame(char *frame)
Function that is called to send an NMEA frame with the checksum appended.
Definition: px_nmea.c:494
void px_nmea_on_rx_byte(uint8_t data)
Function handler that is fed all raw received data.
Definition: px_nmea.c:400
void px_nmea_init(px_nmea_tx_byte_t tx_byte, px_nmea_on_valid_str_t on_valid_str, px_nmea_on_valid_gps_data_t on_valid_gps_data)
Initialise NMEA parser module.
Definition: px_nmea.c:384
Parsed time, position, quality data.
Definition: px_nmea.h:76