gnss14 2.1.0.0
gnss14.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 GNSS14_H
29#define GNSS14_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 GNSS14_RSP_START "$"
75#define GNSS14_RSP_DELIMITER ","
76#define GNSS14_RSP_GNGGA "$GNGGA"
77
82#define GNSS14_GNGGA_ELEMENT_SIZE 15
83#define GNSS14_GNGGA_TIME 1
84#define GNSS14_GNGGA_LATITUDE 2
85#define GNSS14_GNGGA_LATITUDE_SIDE 3
86#define GNSS14_GNGGA_LONGITUDE 4
87#define GNSS14_GNGGA_LONGITUDE_SIDE 5
88#define GNSS14_GNGGA_QUALITY_INDICATOR 6
89#define GNSS14_GNGGA_NUMBER_OF_SATELLITES 7
90#define GNSS14_GNGGA_H_DILUTION_OF_POS 8
91#define GNSS14_GNGGA_ALTITUDE 9
92#define GNSS14_GNGGA_ALTITUDE_UNIT 10
93#define GNSS14_GNGGA_GEOIDAL_SEPARATION 11
94#define GNSS14_GNGGA_GEOIDAL_SEPARATION_UNIT 12
95#define GNSS14_GNGGA_TIME_SINCE_LAST_DGPS 13
96#define GNSS14_GNGGA_DGPS_REFERENCE_STATION_ID 14
97
102#define GNSS14_DUMMY 0xFF
103
109#define GNSS14_SET_DEV_ADDR 0x42
110
116#define GNSS14_DRV_BUFFER_SIZE 200
117
118 // gnss14_set
119
134#define GNSS14_MAP_MIKROBUS( cfg, mikrobus ) \
135 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
136 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
137 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
138 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
139 cfg.io6 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
140 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
141 cfg.eit = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
142 cfg.tp = MIKROBUS( mikrobus, MIKROBUS_INT )
143
144 // gnss14_map
145 // gnss14
146
157
162typedef err_t ( *gnss14_master_io_t )( struct gnss14_s*, uint8_t*, uint8_t );
168typedef struct gnss14_s
169{
170 // Output pins
171 digital_out_t io6;
172 digital_out_t rst;
174 // Input pins
175 digital_in_t eit;
176 digital_in_t tp;
178 // Modules
179 i2c_master_t i2c;
180 uart_t uart;
182 // Buffers
187 pin_name_t chip_select;
194
199typedef struct
200{
201 // Communication gpio pins
202 pin_name_t scl;
203 pin_name_t sda;
204 pin_name_t rx_pin;
205 pin_name_t tx_pin;
207 // Additional gpio pins
208 pin_name_t io6;
209 pin_name_t rst;
210 pin_name_t eit;
211 pin_name_t tp;
213 uint32_t i2c_speed;
214 uint8_t i2c_address;
216 // Static variable
217 uint32_t baud_rate;
219 uart_data_bits_t data_bit;
220 uart_parity_t parity_bit;
221 uart_stop_bits_t stop_bit;
226
231typedef enum
232{
234 GNSS14_ERROR = -1
235
237
254
268err_t gnss14_init ( gnss14_t *ctx, gnss14_cfg_t *cfg );
269
282err_t gnss14_generic_write ( gnss14_t *ctx, uint8_t *data_in, uint16_t len );
283
296err_t gnss14_generic_read ( gnss14_t *ctx, uint8_t *data_out, uint16_t len );
297
306void gnss14_set_io6_pin ( gnss14_t *ctx, uint8_t state );
307
316void gnss14_set_rst_pin ( gnss14_t *ctx, uint8_t state );
317
327
337
347
359err_t gnss14_parse_gngga ( char *rsp_buf, uint8_t gngga_element, char *element_data );
360
361#ifdef __cplusplus
362}
363#endif
364#endif // GNSS14_H
365
366 // gnss14
367
368// ------------------------------------------------------------------------ END
gnss14_return_value_t
GNSS 14 Click return value data.
Definition gnss14.h:232
@ GNSS14_ERROR
Definition gnss14.h:234
@ GNSS14_OK
Definition gnss14.h:233
gnss14_drv_t
GNSS 14 Click driver selector.
Definition gnss14.h:152
@ GNSS14_DRV_SEL_I2C
Definition gnss14.h:154
@ GNSS14_DRV_SEL_UART
Definition gnss14.h:153
err_t(* gnss14_master_io_t)(struct gnss14_s *, uint8_t *, uint8_t)
GNSS 14 Click driver interface.
Definition gnss14.h:162
struct gnss14_s gnss14_t
GNSS 14 Click context object.
#define GNSS14_DRV_BUFFER_SIZE
GNSS 14 driver buffer size.
Definition gnss14.h:116
void gnss14_set_io6_pin(gnss14_t *ctx, uint8_t state)
GNSS 14 set IO6 pin function.
err_t gnss14_generic_write(gnss14_t *ctx, uint8_t *data_in, uint16_t len)
GNSS 14 data writing function.
err_t gnss14_init(gnss14_t *ctx, gnss14_cfg_t *cfg)
GNSS 14 initialization function.
err_t gnss14_parse_gngga(char *rsp_buf, uint8_t gngga_element, char *element_data)
GNSS 14 parse GNGGA function.
void gnss14_cfg_setup(gnss14_cfg_t *cfg)
GNSS 14 configuration object setup function.
void gnss14_set_rst_pin(gnss14_t *ctx, uint8_t state)
GNSS 14 set RST pin function.
void gnss14_reset_device(gnss14_t *ctx)
GNSS 14 reset device function.
uint8_t gnss14_get_eit_pin(gnss14_t *ctx)
GNSS 14 get external interrupt pin state function.
uint8_t gnss14_get_tp_pin(gnss14_t *ctx)
GNSS 14 get time pulse signal pin state function.
err_t gnss14_generic_read(gnss14_t *ctx, uint8_t *data_out, uint16_t len)
GNSS 14 data reading function.
GNSS 14 Click configuration object.
Definition gnss14.h:200
gnss14_drv_t drv_sel
Definition gnss14.h:223
uint32_t baud_rate
Definition gnss14.h:217
pin_name_t io6
Definition gnss14.h:208
uint32_t i2c_speed
Definition gnss14.h:213
pin_name_t tp
Definition gnss14.h:211
bool uart_blocking
Definition gnss14.h:218
uart_data_bits_t data_bit
Definition gnss14.h:219
pin_name_t tx_pin
Definition gnss14.h:205
pin_name_t eit
Definition gnss14.h:210
pin_name_t rx_pin
Definition gnss14.h:204
uart_stop_bits_t stop_bit
Definition gnss14.h:221
pin_name_t scl
Definition gnss14.h:202
uart_parity_t parity_bit
Definition gnss14.h:220
pin_name_t sda
Definition gnss14.h:203
pin_name_t rst
Definition gnss14.h:209
uint8_t i2c_address
Definition gnss14.h:214
GNSS 14 Click context object.
Definition gnss14.h:169
gnss14_master_io_t write_f
Definition gnss14.h:190
gnss14_drv_t drv_sel
Definition gnss14.h:188
digital_in_t tp
Definition gnss14.h:176
uart_t uart
Definition gnss14.h:180
digital_out_t io6
Definition gnss14.h:171
i2c_master_t i2c
Definition gnss14.h:179
digital_out_t rst
Definition gnss14.h:172
uint8_t slave_address
Definition gnss14.h:186
gnss14_master_io_t read_f
Definition gnss14.h:191
pin_name_t chip_select
Definition gnss14.h:187
uint8_t uart_rx_buffer[GNSS14_DRV_BUFFER_SIZE]
Definition gnss14.h:183
uint8_t uart_tx_buffer[GNSS14_DRV_BUFFER_SIZE]
Definition gnss14.h:184
digital_in_t eit
Definition gnss14.h:175