gnss15 2.1.0.0
gnss15.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 GNSS15_H
29#define GNSS15_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 GNSS15_RSP_START "$"
75#define GNSS15_RSP_DELIMITER ","
76#define GNSS15_RSP_END_SEQ "\r\n"
77#define GNSS15_RSP_GPGGA "$GPGGA"
78#define GNSS15_RSP_NO_FIX "0000.00000"
79
84#define GNSS15_GPGGA_ELEMENT_SIZE 15
85#define GNSS15_GPGGA_TIME 1
86#define GNSS15_GPGGA_LATITUDE 2
87#define GNSS15_GPGGA_LATITUDE_SIDE 3
88#define GNSS15_GPGGA_LONGITUDE 4
89#define GNSS15_GPGGA_LONGITUDE_SIDE 5
90#define GNSS15_GPGGA_QUALITY_INDICATOR 6
91#define GNSS15_GPGGA_NUMBER_OF_SATELLITES 7
92#define GNSS15_GPGGA_H_DILUTION_OF_POS 8
93#define GNSS15_GPGGA_ALTITUDE 9
94#define GNSS15_GPGGA_ALTITUDE_UNIT 10
95#define GNSS15_GPGGA_GEOIDAL_SEPARATION 11
96#define GNSS15_GPGGA_GEOIDAL_SEPARATION_UNIT 12
97#define GNSS15_GPGGA_TIME_SINCE_LAST_DGPS 13
98#define GNSS15_GPGGA_DGPS_REFERENCE_STATION_ID 14
99
100
105#define GNSS15_DUMMY 0xFF
106
112#define GNSS15_DEVICE_ADDRESS 0x3A
113
119#define GNSS15_TX_DRV_BUFFER_SIZE 100
120#define GNSS15_RX_DRV_BUFFER_SIZE 300
121
122 // gnss15_cmd
123
138#define GNSS15_MAP_MIKROBUS( cfg, mikrobus ) \
139 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
140 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
141 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
142 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
143 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
144 cfg.wup = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
145 cfg.irq = MIKROBUS( mikrobus, MIKROBUS_INT )
146
147 // gnss15_map
148 // gnss15
149
160
165typedef err_t ( *gnss15_master_io_t )( struct gnss15_s*, uint8_t*, uint8_t );
171typedef struct gnss15_s
172{
173 // Output pins
174 digital_out_t rst;
175 digital_out_t wup;
177 // Input pins
178 digital_in_t irq;
180 // Modules
181 i2c_master_t i2c;
182 uart_t uart;
184 // Buffers
195
200typedef struct
201{
202 // Communication gpio pins
203 pin_name_t rx_pin;
204 pin_name_t tx_pin;
205 pin_name_t scl;
206 pin_name_t sda;
208 // Additional gpio pins
209 pin_name_t rst;
210 pin_name_t wup;
211 pin_name_t irq;
213 // Static variable
214 uint32_t baud_rate;
216 uart_data_bits_t data_bit;
217 uart_parity_t parity_bit;
218 uart_stop_bits_t stop_bit;
220 uint32_t i2c_speed;
221 uint8_t i2c_address;
226
231typedef enum
232{
234 GNSS15_ERROR = -1
235
237
254
268err_t gnss15_init ( gnss15_t *ctx, gnss15_cfg_t *cfg );
269
282err_t gnss15_generic_write ( gnss15_t *ctx, uint8_t *data_in, uint16_t len );
283
296err_t gnss15_generic_read ( gnss15_t *ctx, uint8_t *data_out, uint16_t len );
297
306void gnss15_set_rst_pin ( gnss15_t *ctx, uint8_t state );
307
316void gnss15_set_wup_pin ( gnss15_t *ctx, uint8_t state );
317
327
337
349err_t gnss15_parse_gpgga ( uint8_t *rsp_buf, uint8_t gpgga_element, uint8_t *element_data );
350
351#ifdef __cplusplus
352}
353#endif
354#endif // GNSS15_H
355
356 // gnss15
357
358// ------------------------------------------------------------------------ END
gnss15_return_value_t
GNSS 15 Click return value data.
Definition gnss15.h:232
@ GNSS15_ERROR
Definition gnss15.h:234
@ GNSS15_OK
Definition gnss15.h:233
gnss15_drv_t
GNSS 15 Click driver selector.
Definition gnss15.h:155
@ GNSS15_DRV_SEL_I2C
Definition gnss15.h:157
@ GNSS15_DRV_SEL_UART
Definition gnss15.h:156
err_t(* gnss15_master_io_t)(struct gnss15_s *, uint8_t *, uint8_t)
GNSS 15 Click driver interface.
Definition gnss15.h:165
struct gnss15_s gnss15_t
GNSS 15 Click context object.
#define GNSS15_RX_DRV_BUFFER_SIZE
Definition gnss15.h:120
#define GNSS15_TX_DRV_BUFFER_SIZE
GNSS 15 driver buffer size.
Definition gnss15.h:119
void gnss15_reset_device(gnss15_t *ctx)
GNSS 15 reset device function.
void gnss15_set_rst_pin(gnss15_t *ctx, uint8_t state)
GNSS 15 set RST pin function.
err_t gnss15_init(gnss15_t *ctx, gnss15_cfg_t *cfg)
GNSS 15 initialization function.
void gnss15_set_wup_pin(gnss15_t *ctx, uint8_t state)
GNSS 15 set WUP pin function.
err_t gnss15_generic_write(gnss15_t *ctx, uint8_t *data_in, uint16_t len)
GNSS 15 data writing function.
err_t gnss15_parse_gpgga(uint8_t *rsp_buf, uint8_t gpgga_element, uint8_t *element_data)
GNSS 15 parse GPGGA function.
uint8_t gnss15_get_interrupt(gnss15_t *ctx)
GNSS 15 get interrupt pin state function.
void gnss15_cfg_setup(gnss15_cfg_t *cfg)
GNSS 15 configuration object setup function.
err_t gnss15_generic_read(gnss15_t *ctx, uint8_t *data_out, uint16_t len)
GNSS 15 data reading function.
GNSS 15 Click configuration object.
Definition gnss15.h:201
uint32_t baud_rate
Definition gnss15.h:214
gnss15_drv_t drv_sel
Definition gnss15.h:223
pin_name_t wup
Definition gnss15.h:210
uint32_t i2c_speed
Definition gnss15.h:220
pin_name_t irq
Definition gnss15.h:211
bool uart_blocking
Definition gnss15.h:215
uart_data_bits_t data_bit
Definition gnss15.h:216
pin_name_t tx_pin
Definition gnss15.h:204
pin_name_t rx_pin
Definition gnss15.h:203
uart_stop_bits_t stop_bit
Definition gnss15.h:218
pin_name_t scl
Definition gnss15.h:205
uart_parity_t parity_bit
Definition gnss15.h:217
pin_name_t sda
Definition gnss15.h:206
pin_name_t rst
Definition gnss15.h:209
uint8_t i2c_address
Definition gnss15.h:221
GNSS 15 Click context object.
Definition gnss15.h:172
gnss15_master_io_t write_f
Definition gnss15.h:191
gnss15_drv_t drv_sel
Definition gnss15.h:189
digital_in_t irq
Definition gnss15.h:178
uart_t uart
Definition gnss15.h:182
i2c_master_t i2c
Definition gnss15.h:181
digital_out_t wup
Definition gnss15.h:175
uint8_t uart_rx_buffer[GNSS15_RX_DRV_BUFFER_SIZE]
Definition gnss15.h:185
uint8_t uart_tx_buffer[GNSS15_TX_DRV_BUFFER_SIZE]
Definition gnss15.h:186
digital_out_t rst
Definition gnss15.h:174
uint8_t slave_address
Definition gnss15.h:188
gnss15_master_io_t read_f
Definition gnss15.h:192