gnss4 2.0.0.0
gnss4.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef GNSS4_H
36#define GNSS4_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_uart.h"
55
56
57// -------------------------------------------------------------- PUBLIC MACROS
67#define GNSS4_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
69 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
70 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST )
77#define GNSS4_RETVAL uint8_t
78
79#define GNSS4_OK 0x00
80#define GNSS4_INIT_ERROR 0xFF
87#define GNSS4_NEMA_GNGGA 1
88#define GNSS4_NEMA_GNGLL 3
89#define GNSS4_NEMA_GNGGA_NUM_ELEMENT 15
90#define GNSS4_NEMA_GNGLL_NUM_ELEMENT 5
97#define GNSS4_GNGGA_TIME 1
98#define GNSS4_GNGGA_LATITUDE 2
99#define GNSS4_GNGGA_LATITUDE_SIDE 3
100#define GNSS4_GNGGA_LONGITUDE 4
101#define GNSS4_GNGGA_LONGITUDE_SIDE 5
102#define GNSS4_GNGGA_QUALITY_INDICATOR 6
103#define GNSS4_GNGGA_NUMBER_OF_SATELLITES 7
104#define GNSS4_GNGGA_H_DILUTION_OF_POS 8
105#define GNSS4_GNGGA_ALTITUDE 9
106#define GNSS4_GNGGA_ALTITUDE_UNIT 10
107#define GNSS4_GNGGA_GEOIDAL_SEPARATION 11
108#define GNSS4_GNGGA_GEOIDAL_SEPARATION_UNIT 12
109#define GNSS4_GNGGA_TIME_SINCE_LAST_DGPS 13
110#define GNSS4_GNGGA_DGPS_REFERENCE_STATION_ID 14
117#define GNSS4_GNGLL_LATITUDE 1
118#define GNSS4_GNGLL_LATITUDE_SIDE 2
119#define GNSS4_GNGLL_LONGITUDE 3
120#define GNSS4_GNGLL_LONGITUDE_SIDE 4
127#define GNSS4_ERROR_COMMAND_OR_ELEMENT 0xFF
128#define GNSS4_ERROR_START_OR_END_COMMAND 0x8F
129#define GNSS4_ERROR_NEXT_ELEMENT 0x4F
130#define GNSS4_ERROR_CURRENT_ELEMENT 0x2F
131#define GNSS4_NO_ERROR 0x00
138#define DRV_RX_BUFFER_SIZE 500
141 // End group macro
142// --------------------------------------------------------------- PUBLIC TYPES
150typedef struct
151{
152 // Output pins
153
154 digital_out_t rst;
155
156 // Modules
157
158 uart_t uart;
159
160 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
161 char uart_tx_buffer[ DRV_RX_BUFFER_SIZE ];
162
163} gnss4_t;
164
168typedef struct
169{
170 // Communication gpio pins
171
172 pin_name_t rx_pin;
173 pin_name_t tx_pin;
174
175 // Additional gpio pins
176
177 pin_name_t rst;
178
179 // static variable
180
181 uint32_t baud_rate; // Clock speed.
183 uart_data_bits_t data_bit; // Data bits.
184 uart_parity_t parity_bit; // Parity bit.
185 uart_stop_bits_t stop_bit; // Stop bits.
186
188
192typedef uint8_t gnss4_error_t;
193
194 // End types group
195// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
196
202#ifdef __cplusplus
203extern "C"{
204#endif
205
215
224
230
236void gnss4_set_rst_pin ( gnss4_t *ctx, uint8_t state );
237
244void gnss4_generic_write ( gnss4_t *ctx, char *data_buf, uint16_t len );
245
253int32_t gnss4_generic_read ( gnss4_t *ctx, char *data_buf, uint16_t max_len );
254
264(
265 char *rsp, uint8_t command,
266 uint8_t element, char *parser_buf
267);
268
269#ifdef __cplusplus
270}
271#endif
272#endif // _GNSS4_H_
273
274 // End public_function group
276
277// ------------------------------------------------------------------------- END
#define DRV_RX_BUFFER_SIZE
Definition gnss4.h:138
#define GNSS4_RETVAL
Definition gnss4.h:77
void gnss4_module_wakeup(gnss4_t *ctx)
Wake-up module.
GNSS4_RETVAL gnss4_init(gnss4_t *ctx, gnss4_cfg_t *cfg)
Initialization function.
void gnss4_set_rst_pin(gnss4_t *ctx, uint8_t state)
Set RST ( reset ) pin state.
int32_t gnss4_generic_read(gnss4_t *ctx, char *data_buf, uint16_t max_len)
Generic read function.
gnss4_error_t gnss4_generic_parser(char *rsp, uint8_t command, uint8_t element, char *parser_buf)
Generic parser function.
void gnss4_cfg_setup(gnss4_cfg_t *cfg)
Config Object Initialization function.
void gnss4_generic_write(gnss4_t *ctx, char *data_buf, uint16_t len)
Generic write function.
uint8_t gnss4_error_t
Error type.
Definition gnss4.h:192
Click configuration structure definition.
Definition gnss4.h:169
uint32_t baud_rate
Definition gnss4.h:181
bool uart_blocking
Definition gnss4.h:182
uart_data_bits_t data_bit
Definition gnss4.h:183
pin_name_t tx_pin
Definition gnss4.h:173
pin_name_t rx_pin
Definition gnss4.h:172
uart_stop_bits_t stop_bit
Definition gnss4.h:185
uart_parity_t parity_bit
Definition gnss4.h:184
pin_name_t rst
Definition gnss4.h:177
Click ctx object definition.
Definition gnss4.h:151
uart_t uart
Definition gnss4.h:158
digital_out_t rst
Definition gnss4.h:154