gnss10 2.0.0.0
gnss10.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 GNSS10_H
29#define GNSS10_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 GNSS10_RSP_START "$"
77#define GNSS10_RSP_DELIMITER ","
78#define GNSS10_RSP_GNGGA "$GNGGA"
79
84#define GNSS10_GNGGA_ELEMENT_SIZE 15
85#define GNSS10_GNGGA_TIME 1
86#define GNSS10_GNGGA_LATITUDE 2
87#define GNSS10_GNGGA_LATITUDE_SIDE 3
88#define GNSS10_GNGGA_LONGITUDE 4
89#define GNSS10_GNGGA_LONGITUDE_SIDE 5
90#define GNSS10_GNGGA_QUALITY_INDICATOR 6
91#define GNSS10_GNGGA_NUMBER_OF_SATELLITES 7
92#define GNSS10_GNGGA_H_DILUTION_OF_POS 8
93#define GNSS10_GNGGA_ALTITUDE 9
94#define GNSS10_GNGGA_ALTITUDE_UNIT 10
95#define GNSS10_GNGGA_GEOIDAL_SEPARATION 11
96#define GNSS10_GNGGA_GEOIDAL_SEPARATION_UNIT 12
97#define GNSS10_GNGGA_TIME_SINCE_LAST_DGPS 13
98#define GNSS10_GNGGA_DGPS_REFERENCE_STATION_ID 14
99
104#define GNSS10_DUMMY 0xFF
105
111#define GNSS10_SET_DEV_ADDR 0x42
112
118#define DRV_BUFFER_SIZE 200
119
128#define GNSS10_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
129#define GNSS10_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
130
131 // gnss10_set
132
147#define GNSS10_MAP_MIKROBUS( cfg, mikrobus ) \
148 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
149 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
150 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
151 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
152 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
153 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
154 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
155 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
156 cfg.eint_1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
157 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
158 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
159
160 // gnss10_map
161 // gnss10
162
174
179typedef err_t ( *gnss10_master_io_t )( struct gnss10_s*, uint8_t*, uint8_t );
185typedef struct gnss10_s
186{
187 digital_out_t rst;
189 digital_in_t eint_1;
190 digital_in_t int_pin;
192 i2c_master_t i2c;
193 spi_master_t spi;
194 uart_t uart;
196 // Buffers
201 pin_name_t chip_select;
208
213typedef struct
214{
215 pin_name_t scl;
216 pin_name_t sda;
217 pin_name_t miso;
218 pin_name_t mosi;
219 pin_name_t sck;
220 pin_name_t cs;
221 pin_name_t rx_pin;
222 pin_name_t tx_pin;
223 pin_name_t eint_1;
224 pin_name_t rst;
225 pin_name_t int_pin;
227 uint32_t i2c_speed;
228 uint8_t i2c_address;
230 uint32_t spi_speed;
231 spi_master_mode_t spi_mode;
232 spi_master_chip_select_polarity_t cs_polarity;
234 uint32_t baud_rate;
236 uart_data_bits_t data_bit;
237 uart_parity_t parity_bit;
238 uart_stop_bits_t stop_bit;
243
248typedef enum
249{
251 GNSS10_ERROR = -1
252
254
271
287
302err_t gnss10_init ( gnss10_t *ctx, gnss10_cfg_t *cfg );
303
316err_t gnss10_generic_write ( gnss10_t *ctx, uint8_t *data_in, uint8_t len );
317
330err_t gnss10_generic_read ( gnss10_t *ctx, uint8_t *data_out, uint8_t len );
331
341void gnss10_set_rst_pin ( gnss10_t *ctx, uint8_t state );
342
352
362
372
384err_t gnss10_parse_gngga ( char *rsp_buf, uint8_t gngga_element, char *element_data );
385
386#ifdef __cplusplus
387}
388#endif
389#endif // GNSS10_H
390
391 // gnss10
392
393// ------------------------------------------------------------------------ END
gnss10_drv_t
GNSS 10 Click driver selector.
Definition gnss10.h:168
@ GNSS10_DRV_SEL_UART
Definition gnss10.h:169
@ GNSS10_DRV_SEL_I2C
Definition gnss10.h:171
@ GNSS10_DRV_SEL_SPI
Definition gnss10.h:170
struct gnss10_s gnss10_t
GNSS 10 Click context object.
gnss10_return_value_t
GNSS 10 Click return value data.
Definition gnss10.h:249
@ GNSS10_ERROR
Definition gnss10.h:251
@ GNSS10_OK
Definition gnss10.h:250
err_t(* gnss10_master_io_t)(struct gnss10_s *, uint8_t *, uint8_t)
GNSS 10 Click driver interface.
Definition gnss10.h:179
#define DRV_BUFFER_SIZE
GNSS 10 driver buffer size.
Definition gnss10.h:118
err_t gnss10_parse_gngga(char *rsp_buf, uint8_t gngga_element, char *element_data)
GNSS 10 parse GNGGA function.
err_t gnss10_init(gnss10_t *ctx, gnss10_cfg_t *cfg)
GNSS 10 initialization function.
uint8_t gnss10_get_int_pin(gnss10_t *ctx)
GNSS 10 get INT pin function.
void gnss10_reset_device(gnss10_t *ctx)
GNSS 10 reset device function.
uint8_t gnss10_get_eint_1_pin(gnss10_t *ctx)
GNSS 10 get Ext INT 1 pin function.
err_t gnss10_generic_write(gnss10_t *ctx, uint8_t *data_in, uint8_t len)
GNSS 10 data writing function.
void gnss10_set_rst_pin(gnss10_t *ctx, uint8_t state)
GNSS 10 set RST pin function.
void gnss10_drv_interface_selection(gnss10_cfg_t *cfg, gnss10_drv_t drv_sel)
GNSS 10 driver interface setup function.
void gnss10_cfg_setup(gnss10_cfg_t *cfg)
GNSS 10 configuration object setup function.
err_t gnss10_generic_read(gnss10_t *ctx, uint8_t *data_out, uint8_t len)
GNSS 10 data reading function.
This file contains SPI specific macros, functions, etc.
GNSS 10 Click configuration object.
Definition gnss10.h:214
uint32_t baud_rate
Definition gnss10.h:234
pin_name_t eint_1
Definition gnss10.h:223
gnss10_drv_t drv_sel
Definition gnss10.h:240
uint32_t i2c_speed
Definition gnss10.h:227
spi_master_chip_select_polarity_t cs_polarity
Definition gnss10.h:232
bool uart_blocking
Definition gnss10.h:235
pin_name_t sck
Definition gnss10.h:219
uart_data_bits_t data_bit
Definition gnss10.h:236
spi_master_mode_t spi_mode
Definition gnss10.h:231
pin_name_t tx_pin
Definition gnss10.h:222
pin_name_t mosi
Definition gnss10.h:218
uint32_t spi_speed
Definition gnss10.h:230
pin_name_t rx_pin
Definition gnss10.h:221
uart_stop_bits_t stop_bit
Definition gnss10.h:238
pin_name_t scl
Definition gnss10.h:215
pin_name_t int_pin
Definition gnss10.h:225
pin_name_t miso
Definition gnss10.h:217
uart_parity_t parity_bit
Definition gnss10.h:237
pin_name_t sda
Definition gnss10.h:216
pin_name_t rst
Definition gnss10.h:224
pin_name_t cs
Definition gnss10.h:220
uint8_t i2c_address
Definition gnss10.h:228
GNSS 10 Click context object.
Definition gnss10.h:186
char uart_tx_buffer[DRV_BUFFER_SIZE]
Definition gnss10.h:198
spi_master_t spi
Definition gnss10.h:193
gnss10_master_io_t read_f
Definition gnss10.h:205
gnss10_drv_t drv_sel
Definition gnss10.h:202
gnss10_master_io_t write_f
Definition gnss10.h:204
uart_t uart
Definition gnss10.h:194
digital_in_t int_pin
Definition gnss10.h:190
i2c_master_t i2c
Definition gnss10.h:192
digital_in_t eint_1
Definition gnss10.h:189
digital_out_t rst
Definition gnss10.h:187
uint8_t slave_address
Definition gnss10.h:200
char uart_rx_buffer[DRV_BUFFER_SIZE]
Definition gnss10.h:197
pin_name_t chip_select
Definition gnss10.h:201