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
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 DRV_BUFFER_SIZE_TX 100
74 #define DRV_BUFFER_SIZE_RX 700
75  // 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  // gnssmax_map // gnssmax
101 
106 typedef 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 
128 typedef 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;
146 } gnssmax_cfg_t;
147 
152 typedef enum
153 {
158 
160 
177 
192 err_t gnssmax_init ( gnssmax_t *ctx, gnssmax_cfg_t *cfg );
193 
208 
222 err_t gnssmax_generic_write ( gnssmax_t *ctx, char *data_buf, uint16_t len );
223 
237 err_t gnssmax_generic_read ( gnssmax_t *ctx, char *data_buf, uint16_t max_len );
238 
246 void gnssmax_reset ( gnssmax_t *ctx );
247 
256 void gnssmax_set_external_interrupt ( gnssmax_t *ctx, uint8_t state );
257 
265 uint8_t gnssmax_get_pps ( gnssmax_t *ctx );
266 
267 #ifdef __cplusplus
268 }
269 #endif
270 #endif // GNSSMAX_H
271  // gnssmax
273 
274 // ------------------------------------------------------------------------ END
gnssmax_set_external_interrupt
void gnssmax_set_external_interrupt(gnssmax_t *ctx, uint8_t state)
GNSS MAX sets state of external interrupt.
gnssmax_cfg_t
GNSS MAX Click configuration object.
Definition: gnssmax.h:129
gnssmax_t::uart
uart_t uart
Definition: gnssmax.h:116
gnssmax_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: gnssmax.h:144
gnssmax_default_cfg
err_t gnssmax_default_cfg(gnssmax_t *ctx)
GNSS MAX default configuration function.
gnssmax_t
GNSS MAX Click context object.
Definition: gnssmax.h:107
gnssmax_cfg_setup
void gnssmax_cfg_setup(gnssmax_cfg_t *cfg)
GNSS MAX configuration object setup function.
gnssmax_cfg_t::rst
pin_name_t rst
Definition: gnssmax.h:135
gnssmax_generic_read
err_t gnssmax_generic_read(gnssmax_t *ctx, char *data_buf, uint16_t max_len)
GNSS MAX data reading function.
gnssmax_cfg_t::baud_rate
uint32_t baud_rate
Definition: gnssmax.h:140
gnssmax_t::rst
digital_out_t rst
Definition: gnssmax.h:109
gnssmax_t::ext
digital_out_t ext
Definition: gnssmax.h:110
gnssmax_return_value_t
gnssmax_return_value_t
GNSS MAX Click return value data.
Definition: gnssmax.h:153
gnssmax_cfg_t::ext
pin_name_t ext
Definition: gnssmax.h:136
GNSSMAX_ERROR_NO_DATA
@ GNSSMAX_ERROR_NO_DATA
Definition: gnssmax.h:156
gnssmax_get_pps
uint8_t gnssmax_get_pps(gnssmax_t *ctx)
GNSS MAX reads timestamp pin state.
DRV_BUFFER_SIZE_TX
#define DRV_BUFFER_SIZE_TX
GNSS MAX driver buffer size.
Definition: gnssmax.h:73
gnssmax_init
err_t gnssmax_init(gnssmax_t *ctx, gnssmax_cfg_t *cfg)
GNSS MAX initialization function.
gnssmax_generic_write
err_t gnssmax_generic_write(gnssmax_t *ctx, char *data_buf, uint16_t len)
GNSS MAX data writing function.
gnssmax_t::pps
digital_in_t pps
Definition: gnssmax.h:113
DRV_BUFFER_SIZE_RX
#define DRV_BUFFER_SIZE_RX
Definition: gnssmax.h:74
gnssmax_cfg_t::tx_pin
pin_name_t tx_pin
Definition: gnssmax.h:132
gnssmax_cfg_t::rx_pin
pin_name_t rx_pin
Definition: gnssmax.h:131
GNSSMAX_ERROR_OVERFLOW
@ GNSSMAX_ERROR_OVERFLOW
Definition: gnssmax.h:157
gnssmax_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: gnssmax.h:143
gnssmax_cfg_t::uart_blocking
bool uart_blocking
Definition: gnssmax.h:141
gnssmax_cfg_t::pps
pin_name_t pps
Definition: gnssmax.h:137
GNSSMAX_ERROR
@ GNSSMAX_ERROR
Definition: gnssmax.h:155
gnssmax_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: gnssmax.h:142
GNSSMAX_OK
@ GNSSMAX_OK
Definition: gnssmax.h:154
gnssmax_reset
void gnssmax_reset(gnssmax_t *ctx)
GNSS MAX reset function.