gps6 2.0.0.0
gps6.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef GPS6_H
29#define GPS6_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_uart.h"
52
73#define GPS6_RSP_START "$"
74#define GPS6_RSP_DELIMITER ","
75#define GPS6_RSP_GPGGA "$GPGGA"
76
81#define GPS6_GPGGA_ELEMENT_SIZE 15
82#define GPS6_GPGGA_TIME 1
83#define GPS6_GPGGA_LATITUDE 2
84#define GPS6_GPGGA_LATITUDE_SIDE 3
85#define GPS6_GPGGA_LONGITUDE 4
86#define GPS6_GPGGA_LONGITUDE_SIDE 5
87#define GPS6_GPGGA_QUALITY_INDICATOR 6
88#define GPS6_GPGGA_NUMBER_OF_SATELLITES 7
89#define GPS6_GPGGA_H_DILUTION_OF_POS 8
90#define GPS6_GPGGA_ALTITUDE 9
91#define GPS6_GPGGA_ALTITUDE_UNIT 10
92#define GPS6_GPGGA_GEOIDAL_SEPARATION 11
93#define GPS6_GPGGA_GEOIDAL_SEPARATION_UNIT 12
94#define GPS6_GPGGA_TIME_SINCE_LAST_DGPS 13
95#define GPS6_GPGGA_DGPS_REFERENCE_STATION_ID 14
96
102#define DRV_TX_BUFFER_SIZE 300
103#define DRV_RX_BUFFER_SIZE 100
104
105 // gps6_cmd
106
121#define GPS6_MAP_MIKROBUS( cfg, mikrobus ) \
122 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
123 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
124 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST );
125
126 // gps6_map
127 // gps6
128
133typedef struct
134{
135 // Output pins
136 digital_out_t rst;
138 // Modules
139 uart_t uart;
141 // Buffers
142 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
143 char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
145} gps6_t;
146
151typedef struct
152{
153 // Communication gpio pins
154 pin_name_t rx_pin;
155 pin_name_t tx_pin;
157 // Additional gpio pins
158 pin_name_t rst;
160 // Static variable
161 uint32_t baud_rate;
163 uart_data_bits_t data_bit;
164 uart_parity_t parity_bit;
165 uart_stop_bits_t stop_bit;
167} gps6_cfg_t;
168
173typedef enum
174{
176 GPS6_ERROR = -1
177
179
196
211err_t gps6_init ( gps6_t *ctx, gps6_cfg_t *cfg );
212
226err_t gps6_generic_write ( gps6_t *ctx, char *data_buf, uint16_t len );
227
241err_t gps6_generic_read ( gps6_t *ctx, char *data_buf, uint16_t max_len );
242
252
262
274err_t gps6_parse_gpgga ( char *rsp_buf, uint8_t gpgga_element, char *element_data );
275
276#ifdef __cplusplus
277}
278#endif
279#endif // GPS6_H
280
281 // gps6
282
283// ------------------------------------------------------------------------ END
gps6_return_value_t
GPS 6 Click return value data.
Definition gps6.h:174
@ GPS6_ERROR
Definition gps6.h:176
@ GPS6_OK
Definition gps6.h:175
#define DRV_RX_BUFFER_SIZE
Definition gps6.h:103
#define DRV_TX_BUFFER_SIZE
GPS 6 driver buffer size.
Definition gps6.h:102
err_t gps6_generic_read(gps6_t *ctx, char *data_buf, uint16_t max_len)
GPS 6 data reading function.
err_t gps6_generic_write(gps6_t *ctx, char *data_buf, uint16_t len)
GPS 6 data writing function.
void gps6_cfg_setup(gps6_cfg_t *cfg)
GPS 6 configuration object setup function.
void gps6_enable_device(gps6_t *ctx)
GPS 6 enable device function.
err_t gps6_parse_gpgga(char *rsp_buf, uint8_t gpgga_element, char *element_data)
GPS 6 parse GPGGA function.
void gps6_disable_device(gps6_t *ctx)
GPS 6 disable device function.
err_t gps6_init(gps6_t *ctx, gps6_cfg_t *cfg)
GPS 6 initialization function.
GPS 6 Click configuration object.
Definition gps6.h:152
uint32_t baud_rate
Definition gps6.h:161
bool uart_blocking
Definition gps6.h:162
uart_data_bits_t data_bit
Definition gps6.h:163
pin_name_t tx_pin
Definition gps6.h:155
pin_name_t rx_pin
Definition gps6.h:154
uart_stop_bits_t stop_bit
Definition gps6.h:165
uart_parity_t parity_bit
Definition gps6.h:164
pin_name_t rst
Definition gps6.h:158
GPS 6 Click context object.
Definition gps6.h:134
uart_t uart
Definition gps6.h:139
digital_out_t rst
Definition gps6.h:136