gnss13 2.1.0.0
gnss13.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 GNSS13_H
29#define GNSS13_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#include "drv_i2c_master.h"
53
74#define GNSS13_RSP_START "$"
75#define GNSS13_RSP_DELIMITER ","
76#define GNSS13_RSP_END_SEQ "\r\n"
77#define GNSS13_RSP_GNGGA "$GNGGA"
78
83#define GNSS13_GNGGA_ELEMENT_SIZE 15
84#define GNSS13_GNGGA_TIME 1
85#define GNSS13_GNGGA_LATITUDE 2
86#define GNSS13_GNGGA_LATITUDE_SIDE 3
87#define GNSS13_GNGGA_LONGITUDE 4
88#define GNSS13_GNGGA_LONGITUDE_SIDE 5
89#define GNSS13_GNGGA_QUALITY_INDICATOR 6
90#define GNSS13_GNGGA_NUMBER_OF_SATELLITES 7
91#define GNSS13_GNGGA_H_DILUTION_OF_POS 8
92#define GNSS13_GNGGA_ALTITUDE 9
93#define GNSS13_GNGGA_ALTITUDE_UNIT 10
94#define GNSS13_GNGGA_GEOIDAL_SEPARATION 11
95#define GNSS13_GNGGA_GEOIDAL_SEPARATION_UNIT 12
96#define GNSS13_GNGGA_TIME_SINCE_LAST_DGPS 13
97#define GNSS13_GNGGA_DGPS_REFERENCE_STATION_ID 14
98
104#define GNSS13_DEVICE_ADDRESS 0x10
105
111#define GNSS13_DRV_TX_BUFFER_SIZE 100
112#define GNSS13_DRV_RX_BUFFER_SIZE 1200
113
114 // gnss13_cmd
115
130#define GNSS13_MAP_MIKROBUS( cfg, mikrobus ) \
131 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
132 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
133 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
134 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
135 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
136 cfg.wup = MIKROBUS( mikrobus, MIKROBUS_PWM );
137
138 // gnss13_map
139 // gnss13
140
151
156typedef err_t ( *gnss13_master_io_t )( struct gnss13_s*, uint8_t*, uint8_t );
162typedef struct gnss13_s
163{
164 // Output pins
165 digital_out_t rst;
166 digital_out_t wup;
168 // Modules
169 uart_t uart;
170 i2c_master_t i2c;
172 // Buffers
183
188typedef struct
189{
190 // Communication gpio pins
191 pin_name_t scl;
192 pin_name_t sda;
193 pin_name_t rx_pin;
194 pin_name_t tx_pin;
196 // Additional gpio pins
197 pin_name_t rst;
198 pin_name_t wup;
200 // Static variable
201 uint32_t baud_rate;
203 uart_data_bits_t data_bit;
204 uart_parity_t parity_bit;
205 uart_stop_bits_t stop_bit;
207 uint32_t i2c_speed;
208 uint8_t i2c_address;
213
218typedef enum
219{
221 GNSS13_ERROR = -1
222
224
241
257
271err_t gnss13_init ( gnss13_t *ctx, gnss13_cfg_t *cfg );
272
285err_t gnss13_generic_write ( gnss13_t *ctx, uint8_t *data_in, uint8_t len );
286
299err_t gnss13_generic_read ( gnss13_t *ctx, uint8_t *data_out, uint8_t len );
300
310
320void gnss13_set_rst_pin ( gnss13_t *ctx, uint8_t state );
321
331void gnss13_set_wup_pin ( gnss13_t *ctx, uint8_t state );
332
344err_t gnss13_parse_gngga ( uint8_t *rsp_buf, uint8_t gngga_element, uint8_t *element_data );
345
346#ifdef __cplusplus
347}
348#endif
349#endif // GNSS13_H
350
351 // gnss13
352
353// ------------------------------------------------------------------------ END
gnss13_drv_t
GNSS 13 Click driver selector.
Definition gnss13.h:146
@ GNSS13_DRV_SEL_I2C
Definition gnss13.h:148
@ GNSS13_DRV_SEL_UART
Definition gnss13.h:147
err_t(* gnss13_master_io_t)(struct gnss13_s *, uint8_t *, uint8_t)
GNSS 13 Click driver interface.
Definition gnss13.h:156
gnss13_return_value_t
GNSS 13 Click return value data.
Definition gnss13.h:219
@ GNSS13_OK
Definition gnss13.h:220
@ GNSS13_ERROR
Definition gnss13.h:221
struct gnss13_s gnss13_t
GNSS 13 Click context object.
#define GNSS13_DRV_TX_BUFFER_SIZE
GNSS 13 driver buffer size.
Definition gnss13.h:111
#define GNSS13_DRV_RX_BUFFER_SIZE
Definition gnss13.h:112
err_t gnss13_generic_read(gnss13_t *ctx, uint8_t *data_out, uint8_t len)
GNSS 13 generic read function.
err_t gnss13_parse_gngga(uint8_t *rsp_buf, uint8_t gngga_element, uint8_t *element_data)
GNSS 13 parse GNGGA function.
void gnss13_drv_interface_selection(gnss13_cfg_t *cfg, gnss13_drv_t drv_sel)
GNSS 13 driver interface setup function.
void gnss13_set_wup_pin(gnss13_t *ctx, uint8_t state)
GNSS 13 set WUP pin function.
err_t gnss13_init(gnss13_t *ctx, gnss13_cfg_t *cfg)
GNSS 13 initialization function.
void gnss13_set_rst_pin(gnss13_t *ctx, uint8_t state)
GNSS 13 set RST pin function.
err_t gnss13_generic_write(gnss13_t *ctx, uint8_t *data_in, uint8_t len)
GNSS 13 generic write function.
void gnss13_cfg_setup(gnss13_cfg_t *cfg)
GNSS 13 configuration object setup function.
void gnss13_clear_ring_buffers(gnss13_t *ctx)
GNSS 13 clear ring buffers function.
GNSS 13 Click configuration object.
Definition gnss13.h:189
uint32_t baud_rate
Definition gnss13.h:201
gnss13_drv_t drv_sel
Definition gnss13.h:210
pin_name_t wup
Definition gnss13.h:198
uint32_t i2c_speed
Definition gnss13.h:207
bool uart_blocking
Definition gnss13.h:202
uart_data_bits_t data_bit
Definition gnss13.h:203
pin_name_t tx_pin
Definition gnss13.h:194
pin_name_t rx_pin
Definition gnss13.h:193
uart_stop_bits_t stop_bit
Definition gnss13.h:205
pin_name_t scl
Definition gnss13.h:191
uart_parity_t parity_bit
Definition gnss13.h:204
pin_name_t sda
Definition gnss13.h:192
pin_name_t rst
Definition gnss13.h:197
uint8_t i2c_address
Definition gnss13.h:208
GNSS 13 Click context object.
Definition gnss13.h:163
gnss13_drv_t drv_sel
Definition gnss13.h:177
gnss13_master_io_t write_f
Definition gnss13.h:179
char uart_rx_buffer[GNSS13_DRV_RX_BUFFER_SIZE]
Definition gnss13.h:173
uart_t uart
Definition gnss13.h:169
i2c_master_t i2c
Definition gnss13.h:170
char uart_tx_buffer[GNSS13_DRV_TX_BUFFER_SIZE]
Definition gnss13.h:174
digital_out_t wup
Definition gnss13.h:166
digital_out_t rst
Definition gnss13.h:165
uint8_t slave_address
Definition gnss13.h:176
gnss13_master_io_t read_f
Definition gnss13.h:180