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
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
68#define DRV_BUFFER_SIZE_TX 100
69#define DRV_BUFFER_SIZE_RX 700
70
71 // 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
95 // gnss8_map
96 // gnss8
97
102typedef 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
125typedef 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;
145
158
175
190err_t gnss8_init ( gnss8_t *ctx, gnss8_cfg_t *cfg );
191
205err_t gnss8_generic_write ( gnss8_t *ctx, char *data_buf, uint16_t len );
206
220err_t gnss8_generic_read ( gnss8_t *ctx, char *data_buf, uint16_t max_len );
221
229void gnss8_set_ap_req ( gnss8_t *ctx, uint8_t state );
230
238uint8_t gnss8_get_req ( gnss8_t *ctx );
239
247uint8_t gnss8_get_int ( gnss8_t *ctx );
248
256uint8_t gnss8_get_rdy ( gnss8_t *ctx );
257
258#ifdef __cplusplus
259}
260#endif
261#endif // GNSS8_H
262
263 // gnss8
264
265// ------------------------------------------------------------------------ END
gnss8_return_value_t
GNSS 8 Click return value data.
Definition gnss8.h:151
@ GNSS8_ERROR_OVERFLOW
Definition gnss8.h:155
@ GNSS8_OK
Definition gnss8.h:152
@ GNSS8_ERROR_NO_DATA
Definition gnss8.h:154
@ GNSS8_ERROR
Definition gnss8.h:153
#define DRV_BUFFER_SIZE_TX
GNSS 8 driver buffer size.
Definition gnss8.h:68
#define DRV_BUFFER_SIZE_RX
Definition gnss8.h:69
void gnss8_set_ap_req(gnss8_t *ctx, uint8_t state)
Set AP request pin state.
void gnss8_cfg_setup(gnss8_cfg_t *cfg)
GNSS 8 configuration object setup function.
err_t gnss8_init(gnss8_t *ctx, gnss8_cfg_t *cfg)
GNSS 8 initialization function.
uint8_t gnss8_get_rdy(gnss8_t *ctx)
Get ready pin state.
err_t gnss8_generic_write(gnss8_t *ctx, char *data_buf, uint16_t len)
Data writing function.
err_t gnss8_generic_read(gnss8_t *ctx, char *data_buf, uint16_t max_len)
Data reading function.
uint8_t gnss8_get_req(gnss8_t *ctx)
Get request pin state.
uint8_t gnss8_get_int(gnss8_t *ctx)
Get interrupt pin state.
GNSS 8 Click configuration object.
Definition gnss8.h:126
uint32_t baud_rate
Definition gnss8.h:138
bool uart_blocking
Definition gnss8.h:139
pin_name_t req
Definition gnss8.h:133
uart_data_bits_t data_bit
Definition gnss8.h:140
pin_name_t tx_pin
Definition gnss8.h:129
pin_name_t rx_pin
Definition gnss8.h:128
uart_stop_bits_t stop_bit
Definition gnss8.h:142
pin_name_t int_pin
Definition gnss8.h:135
pin_name_t rdy
Definition gnss8.h:132
uart_parity_t parity_bit
Definition gnss8.h:141
pin_name_t apr
Definition gnss8.h:134
GNSS 8 Click context object.
Definition gnss8.h:103
digital_out_t apr
Definition gnss8.h:105
uart_t uart
Definition gnss8.h:113
digital_in_t int_pin
Definition gnss8.h:110
digital_in_t req
Definition gnss8.h:109
digital_in_t rdy
Definition gnss8.h:108