rtkrover 2.1.0.0
rtkrover.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 RTKROVER_H
29#define RTKROVER_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
73#define RTKROVER_RSP_START "$"
74#define RTKROVER_RSP_DELIMITER ","
75#define RTKROVER_RSP_END_SEQ "\r\n"
76#define RTKROVER_RSP_GNGGA "$GNGGA"
77
82#define RTKROVER_GNGGA_ELEMENT_SIZE 15
83#define RTKROVER_GNGGA_TIME 1
84#define RTKROVER_GNGGA_LATITUDE 2
85#define RTKROVER_GNGGA_LATITUDE_SIDE 3
86#define RTKROVER_GNGGA_LONGITUDE 4
87#define RTKROVER_GNGGA_LONGITUDE_SIDE 5
88#define RTKROVER_GNGGA_QUALITY_INDICATOR 6
89#define RTKROVER_GNGGA_NUMBER_OF_SATELLITES 7
90#define RTKROVER_GNGGA_H_DILUTION_OF_POS 8
91#define RTKROVER_GNGGA_ALTITUDE 9
92#define RTKROVER_GNGGA_ALTITUDE_UNIT 10
93#define RTKROVER_GNGGA_GEOIDAL_SEPARATION 11
94#define RTKROVER_GNGGA_GEOIDAL_SEPARATION_UNIT 12
95#define RTKROVER_GNGGA_TIME_SINCE_LAST_DGPS 13
96#define RTKROVER_GNGGA_DGPS_REFERENCE_STATION_ID 14
97
103#define DRV_TX_BUFFER_SIZE 100
104#define DRV_RX_BUFFER_SIZE 1000
105
106 // rtkrover_cmd
107
122#define RTKROVER_MAP_MIKROBUS( cfg, mikrobus ) \
123 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
124 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
125 cfg.shd = MIKROBUS( mikrobus, MIKROBUS_AN ); \
126 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
127 cfg.wup = MIKROBUS( mikrobus, MIKROBUS_CS ); \
128 cfg.bt = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
129 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
130
131 // rtkrover_map
132 // rtkrover
133
138typedef struct
139{
140 // Output pins
141 digital_out_t shd;
142 digital_out_t rst;
143 digital_out_t wup;
144 digital_out_t bt;
146 // Input pins
147 digital_in_t int_pin;
149 // Modules
150 uart_t uart;
152 // Buffers
153 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
154 char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
156} rtkrover_t;
157
162typedef struct
163{
164 // Communication gpio pins
165 pin_name_t rx_pin;
166 pin_name_t tx_pin;
168 // Additional gpio pins
169 pin_name_t shd;
170 pin_name_t rst;
171 pin_name_t wup;
172 pin_name_t bt;
173 pin_name_t int_pin;
175 // Static variable
176 uint32_t baud_rate;
178 uart_data_bits_t data_bit;
179 uart_parity_t parity_bit;
180 uart_stop_bits_t stop_bit;
183
188typedef enum
189{
191 RTKROVER_ERROR = -1
192
194
211
226
239err_t rtkrover_generic_write ( rtkrover_t *ctx, char *data_in, uint16_t len );
240
253err_t rtkrover_generic_read ( rtkrover_t *ctx, char *data_out, uint16_t len );
254
264
274void rtkrover_set_rst_pin ( rtkrover_t *ctx, uint8_t state );
275
285void rtkrover_set_wup_pin ( rtkrover_t *ctx, uint8_t state );
286
296void rtkrover_set_boot_pin ( rtkrover_t *ctx, uint8_t state );
297
307void rtkrover_set_shd_pin ( rtkrover_t *ctx, uint8_t state );
308
318
330err_t rtkrover_parse_gngga ( char *rsp_buf, uint8_t gngga_element, char *element_data );
331
332#ifdef __cplusplus
333}
334#endif
335#endif // RTKROVER_H
336
337 // rtkrover
338
339// ------------------------------------------------------------------------ END
#define DRV_RX_BUFFER_SIZE
Definition rtkrover.h:104
#define DRV_TX_BUFFER_SIZE
RTK Rover driver buffer size.
Definition rtkrover.h:103
void rtkrover_set_wup_pin(rtkrover_t *ctx, uint8_t state)
RTK Rover set WUP pin function.
void rtkrover_cfg_setup(rtkrover_cfg_t *cfg)
RTK Rover configuration object setup function.
void rtkrover_clear_ring_buffers(rtkrover_t *ctx)
RTK Rover clear ring buffers function.
err_t rtkrover_init(rtkrover_t *ctx, rtkrover_cfg_t *cfg)
RTK Rover initialization function.
void rtkrover_set_rst_pin(rtkrover_t *ctx, uint8_t state)
RTK Rover set RST pin function.
err_t rtkrover_generic_read(rtkrover_t *ctx, char *data_out, uint16_t len)
RTK Rover data reading function.
err_t rtkrover_generic_write(rtkrover_t *ctx, char *data_in, uint16_t len)
RTK Rover data writing function.
err_t rtkrover_parse_gngga(char *rsp_buf, uint8_t gngga_element, char *element_data)
RTK Rover parse GNGGA function.
void rtkrover_set_boot_pin(rtkrover_t *ctx, uint8_t state)
RTK Rover set BOOT pin function.
void rtkrover_set_shd_pin(rtkrover_t *ctx, uint8_t state)
RTK Rover set SHD pin function.
uint8_t rtkrover_get_int_pin(rtkrover_t *ctx)
RTK Rover get INT pin function.
rtkrover_return_value_t
RTK Rover Click return value data.
Definition rtkrover.h:189
@ RTKROVER_OK
Definition rtkrover.h:190
@ RTKROVER_ERROR
Definition rtkrover.h:191
RTK Rover Click configuration object.
Definition rtkrover.h:163
uint32_t baud_rate
Definition rtkrover.h:176
pin_name_t wup
Definition rtkrover.h:171
pin_name_t bt
Definition rtkrover.h:172
bool uart_blocking
Definition rtkrover.h:177
uart_data_bits_t data_bit
Definition rtkrover.h:178
pin_name_t tx_pin
Definition rtkrover.h:166
pin_name_t rx_pin
Definition rtkrover.h:165
pin_name_t shd
Definition rtkrover.h:169
uart_stop_bits_t stop_bit
Definition rtkrover.h:180
pin_name_t int_pin
Definition rtkrover.h:173
uart_parity_t parity_bit
Definition rtkrover.h:179
pin_name_t rst
Definition rtkrover.h:170
RTK Rover Click context object.
Definition rtkrover.h:139
uart_t uart
Definition rtkrover.h:150
digital_in_t int_pin
Definition rtkrover.h:147
digital_out_t wup
Definition rtkrover.h:143
digital_out_t rst
Definition rtkrover.h:142
digital_out_t bt
Definition rtkrover.h:144
digital_out_t shd
Definition rtkrover.h:141