gnss16  2.1.0.0
gnss16.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 GNSS16_H
29 #define GNSS16_H
30 
31 #ifdef __cplusplus
32 extern "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 
73 #define GNSS16_RSP_START "$"
74 #define GNSS16_RSP_DELIMITER ","
75 #define GNSS16_RSP_GNGGA "$GNGGA"
76 
81 #define GNSS16_GNGGA_ELEMENT_SIZE 15
82 #define GNSS16_GNGGA_TIME 1
83 #define GNSS16_GNGGA_LATITUDE 2
84 #define GNSS16_GNGGA_LATITUDE_SIDE 3
85 #define GNSS16_GNGGA_LONGITUDE 4
86 #define GNSS16_GNGGA_LONGITUDE_SIDE 5
87 #define GNSS16_GNGGA_QUALITY_INDICATOR 6
88 #define GNSS16_GNGGA_NUMBER_OF_SATELLITES 7
89 #define GNSS16_GNGGA_H_DILUTION_OF_POS 8
90 #define GNSS16_GNGGA_ALTITUDE 9
91 #define GNSS16_GNGGA_ALTITUDE_UNIT 10
92 #define GNSS16_GNGGA_GEOIDAL_SEPARATION 11
93 #define GNSS16_GNGGA_GEOIDAL_SEPARATION_UNIT 12
94 #define GNSS16_GNGGA_TIME_SINCE_LAST_DGPS 13
95 #define GNSS16_GNGGA_DGPS_REFERENCE_STATION_ID 14
96 
102 #define GNSS16_TX_DRV_BUFFER_SIZE 100
103 #define GNSS16_RX_DRV_BUFFER_SIZE 300
104  // gnss16_cmd
106 
121 #define GNSS16_MAP_MIKROBUS( cfg, mikrobus ) \
122  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
123  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
124  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
125  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
126  // gnss16_map // gnss16
129 
134 typedef struct
135 {
136  // Output pins
137  digital_out_t rst;
139  // Input pins
140  digital_in_t int_pin;
142  // Modules
143  uart_t uart;
145  // Buffers
146  uint8_t uart_rx_buffer[ GNSS16_RX_DRV_BUFFER_SIZE ];
147  uint8_t uart_tx_buffer[ GNSS16_TX_DRV_BUFFER_SIZE ];
149 } gnss16_t;
150 
155 typedef struct
156 {
157  // Communication gpio pins
158  pin_name_t rx_pin;
159  pin_name_t tx_pin;
161  // Additional gpio pins
162  pin_name_t rst;
163  pin_name_t int_pin;
165  // Static variable
166  uint32_t baud_rate;
168  uart_data_bits_t data_bit;
169  uart_parity_t parity_bit;
170  uart_stop_bits_t stop_bit;
172 } gnss16_cfg_t;
173 
178 typedef enum
179 {
181  GNSS16_ERROR = -1
182 
184 
201 
215 err_t gnss16_init ( gnss16_t *ctx, gnss16_cfg_t *cfg );
216 
225 void gnss16_set_rst_pin ( gnss16_t *ctx, uint8_t state );
226 
236 
249 err_t gnss16_generic_write ( gnss16_t *ctx, uint8_t *data_in, uint16_t len );
250 
263 err_t gnss16_generic_read ( gnss16_t *ctx, uint8_t *data_out, uint16_t len );
264 
276 err_t gnss16_parse_gngga ( char *rsp_buf, uint8_t gngga_element, char *element_data );
277 
286 uint8_t gnss16_get_int_pin ( gnss16_t *ctx );
287 
288 #ifdef __cplusplus
289 }
290 #endif
291 #endif // GNSS16_H
292  // gnss16
294 
295 // ------------------------------------------------------------------------ END
gnss16_t::rst
digital_out_t rst
Definition: gnss16.h:137
gnss16_t::int_pin
digital_in_t int_pin
Definition: gnss16.h:140
gnss16_generic_write
err_t gnss16_generic_write(gnss16_t *ctx, uint8_t *data_in, uint16_t len)
GNSS 16 data writing function.
gnss16_parse_gngga
err_t gnss16_parse_gngga(char *rsp_buf, uint8_t gngga_element, char *element_data)
GNSS 16 parse GNGGA function.
gnss16_get_int_pin
uint8_t gnss16_get_int_pin(gnss16_t *ctx)
GNSS 16 get interrupt pin state function.
gnss16_generic_read
err_t gnss16_generic_read(gnss16_t *ctx, uint8_t *data_out, uint16_t len)
GNSS 16 data reading function.
gnss16_set_rst_pin
void gnss16_set_rst_pin(gnss16_t *ctx, uint8_t state)
GNSS 16 set RST pin function.
gnss16_t::uart
uart_t uart
Definition: gnss16.h:143
gnss16_cfg_t::int_pin
pin_name_t int_pin
Definition: gnss16.h:163
gnss16_t
GNSS 16 Click context object.
Definition: gnss16.h:135
gnss16_init
err_t gnss16_init(gnss16_t *ctx, gnss16_cfg_t *cfg)
GNSS 16 initialization function.
gnss16_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: gnss16.h:169
gnss16_cfg_t::uart_blocking
bool uart_blocking
Definition: gnss16.h:167
gnss16_cfg_t::tx_pin
pin_name_t tx_pin
Definition: gnss16.h:159
gnss16_return_value_t
gnss16_return_value_t
GNSS 16 Click return value data.
Definition: gnss16.h:179
gnss16_reset_device
void gnss16_reset_device(gnss16_t *ctx)
GNSS 16 reset device function.
GNSS16_ERROR
@ GNSS16_ERROR
Definition: gnss16.h:181
gnss16_cfg_setup
void gnss16_cfg_setup(gnss16_cfg_t *cfg)
GNSS 16 configuration object setup function.
GNSS16_TX_DRV_BUFFER_SIZE
#define GNSS16_TX_DRV_BUFFER_SIZE
GNSS 16 driver buffer size.
Definition: gnss16.h:102
gnss16_cfg_t
GNSS 16 Click configuration object.
Definition: gnss16.h:156
gnss16_cfg_t::rx_pin
pin_name_t rx_pin
Definition: gnss16.h:158
gnss16_cfg_t::baud_rate
uint32_t baud_rate
Definition: gnss16.h:166
gnss16_cfg_t::rst
pin_name_t rst
Definition: gnss16.h:162
GNSS16_RX_DRV_BUFFER_SIZE
#define GNSS16_RX_DRV_BUFFER_SIZE
Definition: gnss16.h:103
gnss16_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: gnss16.h:168
gnss16_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: gnss16.h:170
GNSS16_OK
@ GNSS16_OK
Definition: gnss16.h:180