gnssmax 2.0.0.0
gnssmax.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 GNSSMAX_H
29#define GNSSMAX_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 DRV_BUFFER_SIZE_TX 100
74#define DRV_BUFFER_SIZE_RX 700
75
76 // gnssmax_set
77
92#define GNSSMAX_MAP_MIKROBUS( cfg, mikrobus ) \
93 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
94 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
95 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
96 cfg.ext = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
97 cfg.pps = MIKROBUS( mikrobus, MIKROBUS_INT );
98
99 // gnssmax_map
100 // gnssmax
101
106typedef struct
107{
108 // Output pins
109 digital_out_t rst;
110 digital_out_t ext;
112 // Input pins
113 digital_in_t pps;
115 // Modules
116 uart_t uart;
118 // Buffers
119 char uart_rx_buffer[ DRV_BUFFER_SIZE_RX ];
120 char uart_tx_buffer[ DRV_BUFFER_SIZE_TX ];
122} gnssmax_t;
123
128typedef struct
129{
130 // Communication gpio pins
131 pin_name_t rx_pin;
132 pin_name_t tx_pin;
134 // Additional gpio pins
135 pin_name_t rst;
136 pin_name_t ext;
137 pin_name_t pps;
139 // Static variable
140 uint32_t baud_rate;
142 uart_data_bits_t data_bit;
143 uart_parity_t parity_bit;
144 uart_stop_bits_t stop_bit;
147
160
177
193
208
222err_t gnssmax_generic_write ( gnssmax_t *ctx, char *data_buf, uint16_t len );
223
237err_t gnssmax_generic_read ( gnssmax_t *ctx, char *data_buf, uint16_t max_len );
238
247
256void gnssmax_set_external_interrupt ( gnssmax_t *ctx, uint8_t state );
257
265uint8_t gnssmax_get_pps ( gnssmax_t *ctx );
266
267#ifdef __cplusplus
268}
269#endif
270#endif // GNSSMAX_H
271
272 // gnssmax
273
274// ------------------------------------------------------------------------ END
gnssmax_return_value_t
GNSS MAX Click return value data.
Definition gnssmax.h:153
@ GNSSMAX_OK
Definition gnssmax.h:154
@ GNSSMAX_ERROR_NO_DATA
Definition gnssmax.h:156
@ GNSSMAX_ERROR_OVERFLOW
Definition gnssmax.h:157
@ GNSSMAX_ERROR
Definition gnssmax.h:155
#define DRV_BUFFER_SIZE_TX
GNSS MAX driver buffer size.
Definition gnssmax.h:73
#define DRV_BUFFER_SIZE_RX
Definition gnssmax.h:74
err_t gnssmax_generic_read(gnssmax_t *ctx, char *data_buf, uint16_t max_len)
GNSS MAX data reading function.
err_t gnssmax_init(gnssmax_t *ctx, gnssmax_cfg_t *cfg)
GNSS MAX initialization function.
void gnssmax_set_external_interrupt(gnssmax_t *ctx, uint8_t state)
GNSS MAX sets state of external interrupt.
err_t gnssmax_default_cfg(gnssmax_t *ctx)
GNSS MAX default configuration function.
void gnssmax_reset(gnssmax_t *ctx)
GNSS MAX reset function.
void gnssmax_cfg_setup(gnssmax_cfg_t *cfg)
GNSS MAX configuration object setup function.
uint8_t gnssmax_get_pps(gnssmax_t *ctx)
GNSS MAX reads timestamp pin state.
err_t gnssmax_generic_write(gnssmax_t *ctx, char *data_buf, uint16_t len)
GNSS MAX data writing function.
GNSS MAX Click configuration object.
Definition gnssmax.h:129
uint32_t baud_rate
Definition gnssmax.h:140
pin_name_t pps
Definition gnssmax.h:137
bool uart_blocking
Definition gnssmax.h:141
uart_data_bits_t data_bit
Definition gnssmax.h:142
pin_name_t tx_pin
Definition gnssmax.h:132
pin_name_t rx_pin
Definition gnssmax.h:131
uart_stop_bits_t stop_bit
Definition gnssmax.h:144
uart_parity_t parity_bit
Definition gnssmax.h:143
pin_name_t ext
Definition gnssmax.h:136
pin_name_t rst
Definition gnssmax.h:135
GNSS MAX Click context object.
Definition gnssmax.h:107
digital_in_t pps
Definition gnssmax.h:113
uart_t uart
Definition gnssmax.h:116
digital_out_t ext
Definition gnssmax.h:110
digital_out_t rst
Definition gnssmax.h:109