gnssrtk 2.1.0.0
gnssrtk.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 GNSSRTK_H
29#define GNSSRTK_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_i2c_master.h"
52#include "drv_spi_master.h"
53#include "drv_uart.h"
54#include "spi_specifics.h"
55
76#define GNSSRTK_RSP_START "$"
77#define GNSSRTK_RSP_DELIMITER ","
78#define GNSSRTK_RSP_GNGGA "$GNGGA"
79
84#define GNSSRTK_GNGGA_ELEMENT_SIZE 15
85#define GNSSRTK_GNGGA_TIME 1
86#define GNSSRTK_GNGGA_LATITUDE 2
87#define GNSSRTK_GNGGA_LATITUDE_SIDE 3
88#define GNSSRTK_GNGGA_LONGITUDE 4
89#define GNSSRTK_GNGGA_LONGITUDE_SIDE 5
90#define GNSSRTK_GNGGA_QUALITY_INDICATOR 6
91#define GNSSRTK_GNGGA_NUMBER_OF_SATELLITES 7
92#define GNSSRTK_GNGGA_H_DILUTION_OF_POS 8
93#define GNSSRTK_GNGGA_ALTITUDE 9
94#define GNSSRTK_GNGGA_ALTITUDE_UNIT 10
95#define GNSSRTK_GNGGA_GEOIDAL_SEPARATION 11
96#define GNSSRTK_GNGGA_GEOIDAL_SEPARATION_UNIT 12
97#define GNSSRTK_GNGGA_TIME_SINCE_LAST_DGPS 13
98#define GNSSRTK_GNGGA_DGPS_REFERENCE_STATION_ID 14
99
104#define GNSSRTK_DUMMY 0xFF
105
111#define GNSSRTK_SET_DEV_ADDR 0x42
112
118#define GNSSRTK_DRV_TX_BUFFER_SIZE 100
119#define GNSSRTK_DRV_RX_BUFFER_SIZE 300
120
129#define GNSSRTK_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
130#define GNSSRTK_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
131
132 // gnssrtk_set
133
148#define GNSSRTK_MAP_MIKROBUS( cfg, mikrobus ) \
149 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
150 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
151 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
152 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
153 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
154 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
155 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
156 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
157 cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_AN ); \
158 cfg.rtk = MIKROBUS( mikrobus, MIKROBUS_RST ); \
159 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
160 cfg.tmp = MIKROBUS( mikrobus, MIKROBUS_INT )
161
162 // gnssrtk_map
163 // gnssrtk
164
176
181typedef err_t ( *gnssrtk_master_io_t )( struct gnssrtk_s*, uint8_t*, uint8_t );
187typedef struct gnssrtk_s
188{
189 digital_out_t rst;
191 digital_in_t rdy;
192 digital_in_t rtk;
193 digital_in_t tmp;
195 i2c_master_t i2c;
196 spi_master_t spi;
197 uart_t uart;
199 // Buffers
204 pin_name_t chip_select;
211
216typedef struct
217{
218 pin_name_t scl;
219 pin_name_t sda;
220 pin_name_t miso;
221 pin_name_t mosi;
222 pin_name_t sck;
223 pin_name_t cs;
224 pin_name_t rx_pin;
225 pin_name_t tx_pin;
227 pin_name_t rdy;
228 pin_name_t rtk;
229 pin_name_t rst;
230 pin_name_t tmp;
232 uint32_t i2c_speed;
233 uint8_t i2c_address;
235 uint32_t spi_speed;
236 spi_master_mode_t spi_mode;
237 spi_master_chip_select_polarity_t cs_polarity;
239 uint32_t baud_rate;
241 uart_data_bits_t data_bit;
242 uart_parity_t parity_bit;
243 uart_stop_bits_t stop_bit;
248
253typedef enum
254{
256 GNSSRTK_ERROR = -1
257
259
276
292
307
320err_t gnssrtk_generic_write ( gnssrtk_t *ctx, uint8_t *data_in, uint8_t len );
321
334err_t gnssrtk_generic_read ( gnssrtk_t *ctx, uint8_t *data_out, uint8_t len );
335
345void gnssrtk_set_rst_pin ( gnssrtk_t *ctx, uint8_t state );
346
356
366
376
386
398err_t gnssrtk_parse_gngga ( char *rsp_buf, uint8_t gngga_element, char *element_data );
399
400#ifdef __cplusplus
401}
402#endif
403#endif // GNSSRTK_H
404
405 // gnssrtk
406
407// ------------------------------------------------------------------------ END
err_t(* gnssrtk_master_io_t)(struct gnssrtk_s *, uint8_t *, uint8_t)
GNSS RTK Click driver interface.
Definition gnssrtk.h:181
gnssrtk_drv_t
GNSS RTK Click driver selector.
Definition gnssrtk.h:170
@ GNSSRTK_DRV_SEL_I2C
Definition gnssrtk.h:173
@ GNSSRTK_DRV_SEL_SPI
Definition gnssrtk.h:172
@ GNSSRTK_DRV_SEL_UART
Definition gnssrtk.h:171
struct gnssrtk_s gnssrtk_t
GNSS RTK Click context object.
gnssrtk_return_value_t
GNSS RTK Click return value data.
Definition gnssrtk.h:254
@ GNSSRTK_ERROR
Definition gnssrtk.h:256
@ GNSSRTK_OK
Definition gnssrtk.h:255
#define GNSSRTK_DRV_RX_BUFFER_SIZE
Definition gnssrtk.h:119
#define GNSSRTK_DRV_TX_BUFFER_SIZE
GNSS RTK driver buffer size.
Definition gnssrtk.h:118
void gnssrtk_cfg_setup(gnssrtk_cfg_t *cfg)
GNSS RTK configuration object setup function.
void gnssrtk_set_rst_pin(gnssrtk_t *ctx, uint8_t state)
GNSS RTK set RST pin function.
uint8_t gnssrtk_get_rdy_pin(gnssrtk_t *ctx)
GNSS RTK get RDY pin function.
void gnssrtk_reset_device(gnssrtk_t *ctx)
GNSS RTK reset device function.
err_t gnssrtk_parse_gngga(char *rsp_buf, uint8_t gngga_element, char *element_data)
GNSS RTK parse GNGGA function.
err_t gnssrtk_init(gnssrtk_t *ctx, gnssrtk_cfg_t *cfg)
GNSS RTK initialization function.
uint8_t gnssrtk_get_tmp_pin(gnssrtk_t *ctx)
GNSS RTK get TMP pin function.
void gnssrtk_drv_interface_selection(gnssrtk_cfg_t *cfg, gnssrtk_drv_t drv_sel)
GNSS RTK driver interface setup function.
uint8_t gnssrtk_get_rtk_pin(gnssrtk_t *ctx)
GNSS RTK get RTK pin function.
err_t gnssrtk_generic_write(gnssrtk_t *ctx, uint8_t *data_in, uint8_t len)
GNSS RTK data writing function.
err_t gnssrtk_generic_read(gnssrtk_t *ctx, uint8_t *data_out, uint8_t len)
GNSS RTK data reading function.
This file contains SPI specific macros, functions, etc.
GNSS RTK Click configuration object.
Definition gnssrtk.h:217
uint32_t baud_rate
Definition gnssrtk.h:239
pin_name_t tmp
Definition gnssrtk.h:230
gnssrtk_drv_t drv_sel
Definition gnssrtk.h:245
uint32_t i2c_speed
Definition gnssrtk.h:232
spi_master_chip_select_polarity_t cs_polarity
Definition gnssrtk.h:237
bool uart_blocking
Definition gnssrtk.h:240
pin_name_t sck
Definition gnssrtk.h:222
uart_data_bits_t data_bit
Definition gnssrtk.h:241
spi_master_mode_t spi_mode
Definition gnssrtk.h:236
pin_name_t tx_pin
Definition gnssrtk.h:225
pin_name_t mosi
Definition gnssrtk.h:221
uint32_t spi_speed
Definition gnssrtk.h:235
pin_name_t rtk
Definition gnssrtk.h:228
pin_name_t rx_pin
Definition gnssrtk.h:224
uart_stop_bits_t stop_bit
Definition gnssrtk.h:243
pin_name_t scl
Definition gnssrtk.h:218
pin_name_t rdy
Definition gnssrtk.h:227
pin_name_t miso
Definition gnssrtk.h:220
uart_parity_t parity_bit
Definition gnssrtk.h:242
pin_name_t sda
Definition gnssrtk.h:219
pin_name_t rst
Definition gnssrtk.h:229
pin_name_t cs
Definition gnssrtk.h:223
uint8_t i2c_address
Definition gnssrtk.h:233
GNSS RTK Click context object.
Definition gnssrtk.h:188
spi_master_t spi
Definition gnssrtk.h:196
char uart_tx_buffer[GNSSRTK_DRV_TX_BUFFER_SIZE]
Definition gnssrtk.h:201
gnssrtk_drv_t drv_sel
Definition gnssrtk.h:205
gnssrtk_master_io_t write_f
Definition gnssrtk.h:207
uart_t uart
Definition gnssrtk.h:197
i2c_master_t i2c
Definition gnssrtk.h:195
char uart_rx_buffer[GNSSRTK_DRV_RX_BUFFER_SIZE]
Definition gnssrtk.h:200
digital_out_t rst
Definition gnssrtk.h:189
digital_in_t rtk
Definition gnssrtk.h:192
uint8_t slave_address
Definition gnssrtk.h:203
digital_in_t tmp
Definition gnssrtk.h:193
gnssrtk_master_io_t read_f
Definition gnssrtk.h:208
pin_name_t chip_select
Definition gnssrtk.h:204
digital_in_t rdy
Definition gnssrtk.h:191