gnss11 2.1.0.0
gnss11.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 GNSS11_H
29#define GNSS11_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 GNSS11_RSP_START "$"
77#define GNSS11_RSP_DELIMITER ","
78#define GNSS11_RSP_END "\r\n"
79#define GNSS11_RSP_GGA "GGA"
80
85#define GNSS11_GGA_ELEMENT_SIZE 15
86#define GNSS11_GGA_TIME 1
87#define GNSS11_GGA_LATITUDE 2
88#define GNSS11_GGA_LATITUDE_SIDE 3
89#define GNSS11_GGA_LONGITUDE 4
90#define GNSS11_GGA_LONGITUDE_SIDE 5
91#define GNSS11_GGA_QUALITY_INDICATOR 6
92#define GNSS11_GGA_NUMBER_OF_SATELLITES 7
93#define GNSS11_GGA_H_DILUTION_OF_POS 8
94#define GNSS11_GGA_ALTITUDE 9
95#define GNSS11_GGA_ALTITUDE_UNIT 10
96#define GNSS11_GGA_GEOIDAL_SEPARATION 11
97#define GNSS11_GGA_GEOIDAL_SEPARATION_UNIT 12
98#define GNSS11_GGA_TIME_SINCE_LAST_DGPS 13
99#define GNSS11_GGA_DGPS_REFERENCE_STATION_ID 14
100
105#define GNSS11_DUMMY 0xFF
106
112#define GNSS11_SET_DEV_ADDR 0x42
113
119#define GNSS11_TX_DRV_BUFFER_SIZE 100
120#define GNSS11_RX_DRV_BUFFER_SIZE 1000
121
130#define GNSS11_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
131#define GNSS11_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
132
133 // gnss11_cmd
134
149#define GNSS11_MAP_MIKROBUS( cfg, mikrobus ) \
150 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
151 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
152 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
153 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
154 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
155 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
156 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
157 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
158 cfg.ovc = MIKROBUS( mikrobus, MIKROBUS_AN ); \
159 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
160 cfg.ant_on = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
161 cfg.eint = MIKROBUS( mikrobus, MIKROBUS_INT );
162
163 // gnss11_map
164 // gnss11
165
177
182struct gnss11_s;
183typedef err_t ( *gnss11_master_io_t )( struct gnss11_s*, uint8_t*, uint16_t );
189typedef struct gnss11_s
190{
191 digital_out_t rst;
192 digital_out_t ant_on;
194 digital_in_t eint;
195 digital_in_t ovc;
197 i2c_master_t i2c;
198 spi_master_t spi;
199 uart_t uart;
205 pin_name_t chip_select;
212
217typedef struct
218{
219 pin_name_t scl;
220 pin_name_t sda;
221 pin_name_t miso;
222 pin_name_t mosi;
223 pin_name_t sck;
224 pin_name_t cs;
225 pin_name_t rx_pin;
226 pin_name_t tx_pin;
227 pin_name_t rst;
228 pin_name_t ant_on;
229 pin_name_t eint;
230 pin_name_t ovc;
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 GNSS11_ERROR = -1
257
259
276
290err_t gnss11_init ( gnss11_t *ctx, gnss11_cfg_t *cfg );
291
307
321
334err_t gnss11_generic_write ( gnss11_t *ctx, uint8_t *data_in, uint16_t len );
335
348err_t gnss11_generic_read ( gnss11_t *ctx, uint8_t *data_out, uint16_t len );
349
359
369void gnss11_set_rst_pin ( gnss11_t *ctx, uint8_t state );
370
380void gnss11_set_ant_on_pin ( gnss11_t *ctx, uint8_t state );
381
391
401
413err_t gnss11_parse_gga ( uint8_t *rsp_buf, uint8_t gga_element, uint8_t *element_data );
414
415#ifdef __cplusplus
416}
417#endif
418#endif // GNSS11_H
419
420 // gnss11
421
422// ------------------------------------------------------------------------ END
err_t(* gnss11_master_io_t)(struct gnss11_s *, uint8_t *, uint16_t)
Definition gnss11.h:183
gnss11_return_value_t
GNSS 11 Click return value data.
Definition gnss11.h:254
@ GNSS11_OK
Definition gnss11.h:255
@ GNSS11_ERROR
Definition gnss11.h:256
gnss11_drv_t
GNSS 11 Click driver selector.
Definition gnss11.h:171
@ GNSS11_DRV_SEL_UART
Definition gnss11.h:172
@ GNSS11_DRV_SEL_SPI
Definition gnss11.h:173
@ GNSS11_DRV_SEL_I2C
Definition gnss11.h:174
struct gnss11_s gnss11_t
GNSS 11 Click context object.
#define GNSS11_TX_DRV_BUFFER_SIZE
GNSS 11 driver buffer size.
Definition gnss11.h:119
#define GNSS11_RX_DRV_BUFFER_SIZE
Definition gnss11.h:120
uint8_t gnss11_get_ovc_pin(gnss11_t *ctx)
GNSS 11 get OVC pin function.
err_t gnss11_default_cfg(gnss11_t *ctx)
GNSS 11 default configuration function.
err_t gnss11_parse_gga(uint8_t *rsp_buf, uint8_t gga_element, uint8_t *element_data)
GNSS 11 parse GGA function.
void gnss11_set_ant_on_pin(gnss11_t *ctx, uint8_t state)
GNSS 11 set ANT_ON pin function.
void gnss11_drv_interface_selection(gnss11_cfg_t *cfg, gnss11_drv_t drv_sel)
GNSS 11 driver interface setup function.
void gnss11_cfg_setup(gnss11_cfg_t *cfg)
GNSS 11 configuration object setup function.
void gnss11_reset_device(gnss11_t *ctx)
GNSS 11 reset device function.
uint8_t gnss11_get_eint_pin(gnss11_t *ctx)
GNSS 11 get Ext INT pin function.
void gnss11_set_rst_pin(gnss11_t *ctx, uint8_t state)
GNSS 11 set RST pin function.
err_t gnss11_generic_read(gnss11_t *ctx, uint8_t *data_out, uint16_t len)
GNSS 11 data reading function.
err_t gnss11_generic_write(gnss11_t *ctx, uint8_t *data_in, uint16_t len)
GNSS 11 data writing function.
err_t gnss11_init(gnss11_t *ctx, gnss11_cfg_t *cfg)
GNSS 11 initialization function.
This file contains SPI specific macros, functions, etc.
GNSS 11 Click configuration object.
Definition gnss11.h:218
uint32_t baud_rate
Definition gnss11.h:239
uint32_t i2c_speed
Definition gnss11.h:232
gnss11_drv_t drv_sel
Definition gnss11.h:245
spi_master_chip_select_polarity_t cs_polarity
Definition gnss11.h:237
bool uart_blocking
Definition gnss11.h:240
pin_name_t sck
Definition gnss11.h:223
uart_data_bits_t data_bit
Definition gnss11.h:241
spi_master_mode_t spi_mode
Definition gnss11.h:236
pin_name_t tx_pin
Definition gnss11.h:226
pin_name_t mosi
Definition gnss11.h:222
uint32_t spi_speed
Definition gnss11.h:235
pin_name_t ovc
Definition gnss11.h:230
pin_name_t ant_on
Definition gnss11.h:228
pin_name_t eint
Definition gnss11.h:229
pin_name_t rx_pin
Definition gnss11.h:225
uart_stop_bits_t stop_bit
Definition gnss11.h:243
pin_name_t scl
Definition gnss11.h:219
pin_name_t miso
Definition gnss11.h:221
uart_parity_t parity_bit
Definition gnss11.h:242
pin_name_t sda
Definition gnss11.h:220
pin_name_t rst
Definition gnss11.h:227
pin_name_t cs
Definition gnss11.h:224
uint8_t i2c_address
Definition gnss11.h:233
GNSS 11 Click context object.
Definition gnss11.h:190
spi_master_t spi
Definition gnss11.h:198
digital_in_t ovc
Definition gnss11.h:195
gnss11_master_io_t read_f
Definition gnss11.h:209
gnss11_drv_t drv_sel
Definition gnss11.h:206
uart_t uart
Definition gnss11.h:199
i2c_master_t i2c
Definition gnss11.h:197
uint8_t uart_rx_buffer[GNSS11_RX_DRV_BUFFER_SIZE]
Definition gnss11.h:201
gnss11_master_io_t write_f
Definition gnss11.h:208
uint8_t uart_tx_buffer[GNSS11_TX_DRV_BUFFER_SIZE]
Definition gnss11.h:202
digital_out_t rst
Definition gnss11.h:191
digital_in_t eint
Definition gnss11.h:194
uint8_t slave_address
Definition gnss11.h:204
pin_name_t chip_select
Definition gnss11.h:205
digital_out_t ant_on
Definition gnss11.h:192