gnss6 2.1.0.0
gnss6.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 GNSS6_H
29#define GNSS6_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_uart.h"
53
74#define GNSS6_RSP_START "$"
75#define GNSS6_RSP_DELIMITER ","
76#define GNSS6_RSP_END_SEQ "\r\n"
77#define GNSS6_RSP_GPGGA "$GPGGA"
78#define GNSS6_RSP_NO_FIX "0000.00000"
79
84#define GNSS6_GPGGA_ELEMENT_SIZE 15
85#define GNSS6_GPGGA_TIME 1
86#define GNSS6_GPGGA_LATITUDE 2
87#define GNSS6_GPGGA_LATITUDE_SIDE 3
88#define GNSS6_GPGGA_LONGITUDE 4
89#define GNSS6_GPGGA_LONGITUDE_SIDE 5
90#define GNSS6_GPGGA_QUALITY_INDICATOR 6
91#define GNSS6_GPGGA_NUMBER_OF_SATELLITES 7
92#define GNSS6_GPGGA_H_DILUTION_OF_POS 8
93#define GNSS6_GPGGA_ALTITUDE 9
94#define GNSS6_GPGGA_ALTITUDE_UNIT 10
95#define GNSS6_GPGGA_GEOIDAL_SEPARATION 11
96#define GNSS6_GPGGA_GEOIDAL_SEPARATION_UNIT 12
97#define GNSS6_GPGGA_TIME_SINCE_LAST_DGPS 13
98#define GNSS6_GPGGA_DGPS_REFERENCE_STATION_ID 14
99
104#define GNSS6_DUMMY 0xFF
105
111#define GNSS6_DEVICE_ADDRESS 0x3A
112
118#define GNSS6_DRV_TX_BUFFER_SIZE 100
119#define GNSS6_DRV_RX_BUFFER_SIZE 300
120
121 // gnss6_cmd
122
137#define GNSS6_MAP_MIKROBUS( cfg, mikrobus ) \
138 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
139 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
140 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
141 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
142 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
143 cfg.wup = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
144 cfg.pps = MIKROBUS( mikrobus, MIKROBUS_INT );
145
146 // gnss6_map
147 // gnss6
148
159
164typedef err_t ( *gnss6_master_io_t )( struct gnss6_s*, uint8_t*, uint8_t );
170typedef struct gnss6_s
171{
172 // Output pins
173 digital_out_t rst;
174 digital_out_t wup;
176 // Input pins
177 digital_in_t pps;
179 // Modules
180 i2c_master_t i2c;
181 uart_t uart;
183 // Buffers
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 rst;
209 pin_name_t wup;
210 pin_name_t pps;
212 // Static variable
213 uint32_t baud_rate;
215 uart_data_bits_t data_bit;
216 uart_parity_t parity_bit;
217 uart_stop_bits_t stop_bit;
220 uint32_t i2c_speed;
221 uint8_t i2c_address;
226
231typedef enum
232{
234 GNSS6_ERROR = -1
235
237
254
270
284err_t gnss6_init ( gnss6_t *ctx, gnss6_cfg_t *cfg );
285
298err_t gnss6_generic_write ( gnss6_t *ctx, uint8_t *data_in, uint8_t len );
299
312err_t gnss6_generic_read ( gnss6_t *ctx, uint8_t *data_out, uint8_t len );
313
323void gnss6_set_rst_pin ( gnss6_t *ctx, uint8_t state );
324
334void gnss6_set_wup_pin ( gnss6_t *ctx, uint8_t state );
335
344uint8_t gnss6_get_pps_pin ( gnss6_t *ctx );
345
355
367err_t gnss6_parse_gpgga ( uint8_t *rsp_buf, uint8_t gpgga_element, uint8_t *element_data );
368
369#ifdef __cplusplus
370}
371#endif
372#endif // GNSS6_H
373
374 // gnss6
375
376// ------------------------------------------------------------------------ END
gnss6_drv_t
GNSS 6 Click driver selector.
Definition gnss6.h:154
@ GNSS6_DRV_SEL_I2C
Definition gnss6.h:156
@ GNSS6_DRV_SEL_UART
Definition gnss6.h:155
gnss6_return_value_t
GNSS 6 Click return value data.
Definition gnss6.h:232
@ GNSS6_ERROR
Definition gnss6.h:234
@ GNSS6_OK
Definition gnss6.h:233
err_t(* gnss6_master_io_t)(struct gnss6_s *, uint8_t *, uint8_t)
GNSS 6 Click driver interface.
Definition gnss6.h:164
struct gnss6_s gnss6_t
GNSS 6 Click context object.
#define GNSS6_DRV_TX_BUFFER_SIZE
GNSS 6 driver buffer size.
Definition gnss6.h:118
#define GNSS6_DRV_RX_BUFFER_SIZE
Definition gnss6.h:119
err_t gnss6_init(gnss6_t *ctx, gnss6_cfg_t *cfg)
GNSS 6 initialization function.
void gnss6_set_rst_pin(gnss6_t *ctx, uint8_t state)
GNSS 6 set RST pin function.
uint8_t gnss6_get_pps_pin(gnss6_t *ctx)
GNSS 6 get PPS pin function.
err_t gnss6_generic_read(gnss6_t *ctx, uint8_t *data_out, uint8_t len)
GNSS 6 data reading function.
void gnss6_reset_device(gnss6_t *ctx)
GNSS 6 reset device function.
err_t gnss6_parse_gpgga(uint8_t *rsp_buf, uint8_t gpgga_element, uint8_t *element_data)
GNSS 6 parse GPGGA function.
err_t gnss6_generic_write(gnss6_t *ctx, uint8_t *data_in, uint8_t len)
GNSS 6 data writing function.
void gnss6_set_wup_pin(gnss6_t *ctx, uint8_t state)
GNSS 6 set WUP pin function.
void gnss6_cfg_setup(gnss6_cfg_t *cfg)
GNSS 6 configuration object setup function.
void gnss6_drv_interface_selection(gnss6_cfg_t *cfg, gnss6_drv_t drv_sel)
GNSS 6 driver interface setup function.
GNSS 6 Click configuration object.
Definition gnss6.h:200
uint32_t baud_rate
Definition gnss6.h:213
pin_name_t wup
Definition gnss6.h:209
pin_name_t pps
Definition gnss6.h:210
uint32_t i2c_speed
Definition gnss6.h:220
bool uart_blocking
Definition gnss6.h:214
gnss6_drv_t drv_sel
Definition gnss6.h:223
uart_data_bits_t data_bit
Definition gnss6.h:215
pin_name_t tx_pin
Definition gnss6.h:205
pin_name_t rx_pin
Definition gnss6.h:204
uart_stop_bits_t stop_bit
Definition gnss6.h:217
pin_name_t scl
Definition gnss6.h:202
uart_parity_t parity_bit
Definition gnss6.h:216
pin_name_t sda
Definition gnss6.h:203
pin_name_t rst
Definition gnss6.h:208
uint8_t i2c_address
Definition gnss6.h:221
GNSS 6 Click context object.
Definition gnss6.h:171
uint8_t uart_tx_buffer[GNSS6_DRV_TX_BUFFER_SIZE]
Definition gnss6.h:185
digital_in_t pps
Definition gnss6.h:177
uint8_t uart_rx_buffer[GNSS6_DRV_RX_BUFFER_SIZE]
Definition gnss6.h:184
gnss6_master_io_t write_f
Definition gnss6.h:190
gnss6_drv_t drv_sel
Definition gnss6.h:188
gnss6_master_io_t read_f
Definition gnss6.h:191
uart_t uart
Definition gnss6.h:181
i2c_master_t i2c
Definition gnss6.h:180
digital_out_t wup
Definition gnss6.h:174
digital_out_t rst
Definition gnss6.h:173
uint8_t slave_address
Definition gnss6.h:187