gnsszoe 2.0.0.0
gnsszoe.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 GNSSZOE_H
29#define GNSSZOE_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_spi_master.h"
53#include "drv_uart.h"
54#include "spi_specifics.h"
55
76#define GNSSZOE_RSP_START "$"
77#define GNSSZOE_RSP_DELIMITER ","
78#define GNSSZOE_RSP_GNGGA "$GNGGA"
79
84#define GNSSZOE_GNGGA_ELEMENT_SIZE 15
85#define GNSSZOE_GNGGA_TIME 1
86#define GNSSZOE_GNGGA_LATITUDE 2
87#define GNSSZOE_GNGGA_LATITUDE_SIDE 3
88#define GNSSZOE_GNGGA_LONGITUDE 4
89#define GNSSZOE_GNGGA_LONGITUDE_SIDE 5
90#define GNSSZOE_GNGGA_QUALITY_INDICATOR 6
91#define GNSSZOE_GNGGA_NUMBER_OF_SATELLITES 7
92#define GNSSZOE_GNGGA_H_DILUTION_OF_POS 8
93#define GNSSZOE_GNGGA_ALTITUDE 9
94#define GNSSZOE_GNGGA_ALTITUDE_UNIT 10
95#define GNSSZOE_GNGGA_GEOIDAL_SEPARATION 11
96#define GNSSZOE_GNGGA_GEOIDAL_SEPARATION_UNIT 12
97#define GNSSZOE_GNGGA_TIME_SINCE_LAST_DGPS 13
98#define GNSSZOE_GNGGA_DGPS_REFERENCE_STATION_ID 14
99
104#define GNSSZOE_DUMMY 0xFF
105
111#define GNSSZOE_SET_DEV_ADDR 0x42
112
118#define GNSSZOE_DRV_TX_BUFFER_SIZE 100
119#define GNSSZOE_DRV_RX_BUFFER_SIZE 600
120
129#define GNSSZOE_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
130#define GNSSZOE_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
131
132 // gnsszoe_set
133
148#define GNSSZOE_MAP_MIKROBUS( cfg, mikrobus ) \
149 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
150 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
151 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
152 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
153 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
154 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
155 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
156 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
157 cfg.exi = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
158 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST )
159
160 // gnsszoe_map
161 // gnsszoe
162
174
179typedef err_t ( *gnsszoe_master_io_t )( struct gnsszoe_s*, uint8_t*, uint8_t );
207
212typedef struct
213{
214 pin_name_t scl;
215 pin_name_t sda;
216 pin_name_t miso;
217 pin_name_t mosi;
218 pin_name_t sck;
219 pin_name_t cs;
220 pin_name_t rx_pin;
221 pin_name_t tx_pin;
223 pin_name_t exi;
224 pin_name_t rst;
226 uint32_t i2c_speed;
227 uint8_t i2c_address;
229 uint32_t spi_speed;
230 spi_master_mode_t spi_mode;
231 spi_master_chip_select_polarity_t cs_polarity;
233 uint32_t baud_rate;
235 uart_data_bits_t data_bit;
236 uart_parity_t parity_bit;
237 uart_stop_bits_t stop_bit;
242
247typedef enum
248{
250 GNSSZOE_ERROR = -1
251
253
270
286
301
314err_t gnsszoe_generic_write ( gnsszoe_t *ctx, uint8_t *data_in, uint8_t len );
315
328err_t gnsszoe_generic_read ( gnsszoe_t *ctx, uint8_t *data_out, uint8_t len );
329
339void gnsszoe_set_rst_pin ( gnsszoe_t *ctx, uint8_t state );
340
350
360
372err_t gnsszoe_parse_gngga ( char *rsp_buf, uint8_t gngga_element, char *element_data );
373
374#ifdef __cplusplus
375}
376#endif
377#endif // GNSSZOE_H
378
379 // gnsszoe
380
381// ------------------------------------------------------------------------ END
gnsszoe_drv_t
GNSS ZOE Click driver selector.
Definition gnsszoe.h:168
@ GNSSZOE_DRV_SEL_SPI
Definition gnsszoe.h:170
@ GNSSZOE_DRV_SEL_I2C
Definition gnsszoe.h:171
@ GNSSZOE_DRV_SEL_UART
Definition gnsszoe.h:169
struct gnsszoe_s gnsszoe_t
GNSS ZOE Click context object.
gnsszoe_return_value_t
GNSS ZOE Click return value data.
Definition gnsszoe.h:248
@ GNSSZOE_OK
Definition gnsszoe.h:249
@ GNSSZOE_ERROR
Definition gnsszoe.h:250
err_t(* gnsszoe_master_io_t)(struct gnsszoe_s *, uint8_t *, uint8_t)
GNSS ZOE Click driver interface.
Definition gnsszoe.h:179
#define GNSSZOE_DRV_TX_BUFFER_SIZE
GNSS ZOE driver buffer size.
Definition gnsszoe.h:118
#define GNSSZOE_DRV_RX_BUFFER_SIZE
Definition gnsszoe.h:119
err_t gnsszoe_generic_read(gnsszoe_t *ctx, uint8_t *data_out, uint8_t len)
GNSS ZOE data reading function.
void gnsszoe_cfg_setup(gnsszoe_cfg_t *cfg)
GNSS ZOE configuration object setup function.
void gnsszoe_set_rst_pin(gnsszoe_t *ctx, uint8_t state)
GNSS ZOE set RST pin function.
err_t gnsszoe_init(gnsszoe_t *ctx, gnsszoe_cfg_t *cfg)
GNSS ZOE initialization function.
err_t gnsszoe_generic_write(gnsszoe_t *ctx, uint8_t *data_in, uint8_t len)
GNSS ZOE data writing function.
void gnsszoe_reset_device(gnsszoe_t *ctx)
GNSS ZOE reset device function.
void gnsszoe_drv_interface_selection(gnsszoe_cfg_t *cfg, gnsszoe_drv_t drv_sel)
GNSS ZOE driver interface setup function.
err_t gnsszoe_parse_gngga(char *rsp_buf, uint8_t gngga_element, char *element_data)
GNSS ZOE parse GNGGA function.
uint8_t gnsszoe_get_exi_pin(gnsszoe_t *ctx)
GNSS ZOE get EXI pin function.
This file contains SPI specific macros, functions, etc.
GNSS ZOE Click configuration object.
Definition gnsszoe.h:213
uint32_t baud_rate
Definition gnsszoe.h:233
gnsszoe_drv_t drv_sel
Definition gnsszoe.h:239
uint32_t i2c_speed
Definition gnsszoe.h:226
spi_master_chip_select_polarity_t cs_polarity
Definition gnsszoe.h:231
bool uart_blocking
Definition gnsszoe.h:234
pin_name_t sck
Definition gnsszoe.h:218
uart_data_bits_t data_bit
Definition gnsszoe.h:235
spi_master_mode_t spi_mode
Definition gnsszoe.h:230
pin_name_t tx_pin
Definition gnsszoe.h:221
pin_name_t mosi
Definition gnsszoe.h:217
uint32_t spi_speed
Definition gnsszoe.h:229
pin_name_t rx_pin
Definition gnsszoe.h:220
uart_stop_bits_t stop_bit
Definition gnsszoe.h:237
pin_name_t scl
Definition gnsszoe.h:214
pin_name_t miso
Definition gnsszoe.h:216
uart_parity_t parity_bit
Definition gnsszoe.h:236
pin_name_t sda
Definition gnsszoe.h:215
pin_name_t rst
Definition gnsszoe.h:224
pin_name_t exi
Definition gnsszoe.h:223
pin_name_t cs
Definition gnsszoe.h:219
uint8_t i2c_address
Definition gnsszoe.h:227
GNSS ZOE Click context object.
Definition gnsszoe.h:186
spi_master_t spi
Definition gnsszoe.h:192
gnsszoe_master_io_t write_f
Definition gnsszoe.h:203
gnsszoe_drv_t drv_sel
Definition gnsszoe.h:201
char uart_tx_buffer[GNSSZOE_DRV_TX_BUFFER_SIZE]
Definition gnsszoe.h:197
digital_in_t exi
Definition gnsszoe.h:189
uart_t uart
Definition gnsszoe.h:193
char uart_rx_buffer[GNSSZOE_DRV_RX_BUFFER_SIZE]
Definition gnsszoe.h:196
i2c_master_t i2c
Definition gnsszoe.h:191
gnsszoe_master_io_t read_f
Definition gnsszoe.h:204
digital_out_t rst
Definition gnsszoe.h:187
uint8_t slave_address
Definition gnsszoe.h:199
pin_name_t chip_select
Definition gnsszoe.h:200