gnss8  2.0.0.0
gnss8.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 GNSS8_H
29 #define GNSS8_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 
68 #define DRV_BUFFER_SIZE_TX 100
69 #define DRV_BUFFER_SIZE_RX 700
70  // gnss8_set
72 
87 #define GNSS8_MAP_MIKROBUS( cfg, mikrobus ) \
88  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
89  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
90  cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_AN ); \
91  cfg.req = MIKROBUS( mikrobus, MIKROBUS_RST ); \
92  cfg.apr = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
93  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
94  // gnss8_map // gnss8
97 
102 typedef struct
103 {
104  // Output pins
105  digital_out_t apr;
107  // Input pins
108  digital_in_t rdy;
109  digital_in_t req;
110  digital_in_t int_pin;
112  // Modules
113  uart_t uart;
115  // Buffers
116  char uart_rx_buffer[ DRV_BUFFER_SIZE_RX ];
117  char uart_tx_buffer[ DRV_BUFFER_SIZE_TX ];
119 } gnss8_t;
120 
125 typedef struct
126 {
127  // Communication gpio pins
128  pin_name_t rx_pin;
129  pin_name_t tx_pin;
131  // Additional gpio pins
132  pin_name_t rdy;
133  pin_name_t req;
134  pin_name_t apr;
135  pin_name_t int_pin;
137  // Static variable
138  uint32_t baud_rate;
140  uart_data_bits_t data_bit;
141  uart_parity_t parity_bit;
142  uart_stop_bits_t stop_bit;
144 } gnss8_cfg_t;
145 
150 typedef enum
151 {
152  GNSS8_OK = 0,
156 
158 
175 
190 err_t gnss8_init ( gnss8_t *ctx, gnss8_cfg_t *cfg );
191 
205 err_t gnss8_generic_write ( gnss8_t *ctx, char *data_buf, uint16_t len );
206 
220 err_t gnss8_generic_read ( gnss8_t *ctx, char *data_buf, uint16_t max_len );
221 
229 void gnss8_set_ap_req ( gnss8_t *ctx, uint8_t state );
230 
238 uint8_t gnss8_get_req ( gnss8_t *ctx );
239 
247 uint8_t gnss8_get_int ( gnss8_t *ctx );
248 
256 uint8_t gnss8_get_rdy ( gnss8_t *ctx );
257 
258 #ifdef __cplusplus
259 }
260 #endif
261 #endif // GNSS8_H
262  // gnss8
264 
265 // ------------------------------------------------------------------------ END
gnss8_get_rdy
uint8_t gnss8_get_rdy(gnss8_t *ctx)
Get ready pin state.
gnss8_t::apr
digital_out_t apr
Definition: gnss8.h:105
gnss8_cfg_t::rx_pin
pin_name_t rx_pin
Definition: gnss8.h:128
gnss8_init
err_t gnss8_init(gnss8_t *ctx, gnss8_cfg_t *cfg)
GNSS 8 initialization function.
gnss8_cfg_t::int_pin
pin_name_t int_pin
Definition: gnss8.h:135
gnss8_t::rdy
digital_in_t rdy
Definition: gnss8.h:108
gnss8_cfg_t::uart_blocking
bool uart_blocking
Definition: gnss8.h:139
gnss8_get_req
uint8_t gnss8_get_req(gnss8_t *ctx)
Get request pin state.
gnss8_cfg_t::req
pin_name_t req
Definition: gnss8.h:133
gnss8_t
GNSS 8 Click context object.
Definition: gnss8.h:103
gnss8_cfg_t::tx_pin
pin_name_t tx_pin
Definition: gnss8.h:129
GNSS8_ERROR_NO_DATA
@ GNSS8_ERROR_NO_DATA
Definition: gnss8.h:154
gnss8_t::req
digital_in_t req
Definition: gnss8.h:109
gnss8_generic_read
err_t gnss8_generic_read(gnss8_t *ctx, char *data_buf, uint16_t max_len)
Data reading function.
DRV_BUFFER_SIZE_RX
#define DRV_BUFFER_SIZE_RX
Definition: gnss8.h:69
gnss8_return_value_t
gnss8_return_value_t
GNSS 8 Click return value data.
Definition: gnss8.h:151
gnss8_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: gnss8.h:142
gnss8_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: gnss8.h:140
gnss8_t::int_pin
digital_in_t int_pin
Definition: gnss8.h:110
gnss8_generic_write
err_t gnss8_generic_write(gnss8_t *ctx, char *data_buf, uint16_t len)
Data writing function.
GNSS8_ERROR_OVERFLOW
@ GNSS8_ERROR_OVERFLOW
Definition: gnss8.h:155
gnss8_set_ap_req
void gnss8_set_ap_req(gnss8_t *ctx, uint8_t state)
Set AP request pin state.
gnss8_get_int
uint8_t gnss8_get_int(gnss8_t *ctx)
Get interrupt pin state.
GNSS8_ERROR
@ GNSS8_ERROR
Definition: gnss8.h:153
gnss8_t::uart
uart_t uart
Definition: gnss8.h:113
gnss8_cfg_t::apr
pin_name_t apr
Definition: gnss8.h:134
gnss8_cfg_t::rdy
pin_name_t rdy
Definition: gnss8.h:132
gnss8_cfg_t
GNSS 8 Click configuration object.
Definition: gnss8.h:126
DRV_BUFFER_SIZE_TX
#define DRV_BUFFER_SIZE_TX
GNSS 8 driver buffer size.
Definition: gnss8.h:68
gnss8_cfg_setup
void gnss8_cfg_setup(gnss8_cfg_t *cfg)
GNSS 8 configuration object setup function.
GNSS8_OK
@ GNSS8_OK
Definition: gnss8.h:152
gnss8_cfg_t::baud_rate
uint32_t baud_rate
Definition: gnss8.h:138
gnss8_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: gnss8.h:141