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 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_uart.h"
38 
59 #define DRV_BUFFER_SIZE_TX 100
60 #define DRV_BUFFER_SIZE_RX 700
61  // gnssmax_set
63 
78 #define GNSSMAX_MAP_MIKROBUS( cfg, mikrobus ) \
79  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
80  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
81  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
82  cfg.ext = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
83  cfg.pps = MIKROBUS( mikrobus, MIKROBUS_INT );
84  // gnssmax_map // gnssmax
87 
92 typedef struct
93 {
94  // Output pins
95  digital_out_t rst;
96  digital_out_t ext;
98  // Input pins
99  digital_in_t pps;
101  // Modules
102  uart_t uart;
104  // Buffers
105  char uart_rx_buffer[ DRV_BUFFER_SIZE_RX ];
106  char uart_tx_buffer[ DRV_BUFFER_SIZE_TX ];
108 } gnssmax_t;
109 
114 typedef struct
115 {
116  // Communication gpio pins
117  pin_name_t rx_pin;
118  pin_name_t tx_pin;
120  // Additional gpio pins
121  pin_name_t rst;
122  pin_name_t ext;
123  pin_name_t pps;
125  // Static variable
126  uint32_t baud_rate;
128  uart_data_bits_t data_bit;
129  uart_parity_t parity_bit;
130  uart_stop_bits_t stop_bit;
132 } gnssmax_cfg_t;
133 
138 typedef enum
139 {
144 
146 
163 
178 err_t gnssmax_init ( gnssmax_t *ctx, gnssmax_cfg_t *cfg );
179 
194 
208 err_t gnssmax_generic_write ( gnssmax_t *ctx, char *data_buf, uint16_t len );
209 
223 err_t gnssmax_generic_read ( gnssmax_t *ctx, char *data_buf, uint16_t max_len );
224 
232 void gnssmax_reset ( gnssmax_t *ctx );
233 
242 void gnssmax_set_external_interrupt ( gnssmax_t *ctx, uint8_t state );
243 
251 uint8_t gnssmax_get_pps ( gnssmax_t *ctx );
252 
253 #ifdef __cplusplus
254 }
255 #endif
256 #endif // GNSSMAX_H
257  // gnssmax
259 
260 // ------------------------------------------------------------------------ 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:115
gnssmax_t::uart
uart_t uart
Definition: gnssmax.h:102
gnssmax_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: gnssmax.h:130
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:93
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:121
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:126
gnssmax_t::rst
digital_out_t rst
Definition: gnssmax.h:95
gnssmax_t::ext
digital_out_t ext
Definition: gnssmax.h:96
gnssmax_return_value_t
gnssmax_return_value_t
GNSS MAX Click return value data.
Definition: gnssmax.h:139
gnssmax_cfg_t::ext
pin_name_t ext
Definition: gnssmax.h:122
GNSSMAX_ERROR_NO_DATA
@ GNSSMAX_ERROR_NO_DATA
Definition: gnssmax.h:142
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:59
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:99
DRV_BUFFER_SIZE_RX
#define DRV_BUFFER_SIZE_RX
Definition: gnssmax.h:60
gnssmax_cfg_t::tx_pin
pin_name_t tx_pin
Definition: gnssmax.h:118
gnssmax_cfg_t::rx_pin
pin_name_t rx_pin
Definition: gnssmax.h:117
GNSSMAX_ERROR_OVERFLOW
@ GNSSMAX_ERROR_OVERFLOW
Definition: gnssmax.h:143
gnssmax_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: gnssmax.h:129
gnssmax_cfg_t::uart_blocking
bool uart_blocking
Definition: gnssmax.h:127
gnssmax_cfg_t::pps
pin_name_t pps
Definition: gnssmax.h:123
GNSSMAX_ERROR
@ GNSSMAX_ERROR
Definition: gnssmax.h:141
gnssmax_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: gnssmax.h:128
GNSSMAX_OK
@ GNSSMAX_OK
Definition: gnssmax.h:140
gnssmax_reset
void gnssmax_reset(gnssmax_t *ctx)
GNSS MAX reset function.