gps6  2.0.0.0
gps6.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 GPS6_H
29 #define GPS6_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 GPS6_RSP_START "$"
60 #define GPS6_RSP_DELIMITER ","
61 #define GPS6_RSP_GPGGA "$GPGGA"
62 
67 #define GPS6_GPGGA_ELEMENT_SIZE 15
68 #define GPS6_GPGGA_TIME 1
69 #define GPS6_GPGGA_LATITUDE 2
70 #define GPS6_GPGGA_LATITUDE_SIDE 3
71 #define GPS6_GPGGA_LONGITUDE 4
72 #define GPS6_GPGGA_LONGITUDE_SIDE 5
73 #define GPS6_GPGGA_QUALITY_INDICATOR 6
74 #define GPS6_GPGGA_NUMBER_OF_SATELLITES 7
75 #define GPS6_GPGGA_H_DILUTION_OF_POS 8
76 #define GPS6_GPGGA_ALTITUDE 9
77 #define GPS6_GPGGA_ALTITUDE_UNIT 10
78 #define GPS6_GPGGA_GEOIDAL_SEPARATION 11
79 #define GPS6_GPGGA_GEOIDAL_SEPARATION_UNIT 12
80 #define GPS6_GPGGA_TIME_SINCE_LAST_DGPS 13
81 #define GPS6_GPGGA_DGPS_REFERENCE_STATION_ID 14
82 
88 #define DRV_TX_BUFFER_SIZE 300
89 #define DRV_RX_BUFFER_SIZE 100
90  // gps6_cmd
92 
107 #define GPS6_MAP_MIKROBUS( cfg, mikrobus ) \
108  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
109  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
110  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST );
111  // gps6_map // gps6
114 
119 typedef struct
120 {
121  // Output pins
122  digital_out_t rst;
124  // Modules
125  uart_t uart;
127  // Buffers
128  char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
129  char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
131 } gps6_t;
132 
137 typedef struct
138 {
139  // Communication gpio pins
140  pin_name_t rx_pin;
141  pin_name_t tx_pin;
143  // Additional gpio pins
144  pin_name_t rst;
146  // Static variable
147  uint32_t baud_rate;
149  uart_data_bits_t data_bit;
150  uart_parity_t parity_bit;
151  uart_stop_bits_t stop_bit;
153 } gps6_cfg_t;
154 
159 typedef enum
160 {
161  GPS6_OK = 0,
162  GPS6_ERROR = -1
163 
165 
182 
197 err_t gps6_init ( gps6_t *ctx, gps6_cfg_t *cfg );
198 
212 err_t gps6_generic_write ( gps6_t *ctx, char *data_buf, uint16_t len );
213 
227 err_t gps6_generic_read ( gps6_t *ctx, char *data_buf, uint16_t max_len );
228 
238 
248 
260 err_t gps6_parse_gpgga ( char *rsp_buf, uint8_t gpgga_element, char *element_data );
261 
262 #ifdef __cplusplus
263 }
264 #endif
265 #endif // GPS6_H
266  // gps6
268 
269 // ------------------------------------------------------------------------ END
gps6_disable_device
void gps6_disable_device(gps6_t *ctx)
GPS 6 disable device function.
gps6_cfg_t::rst
pin_name_t rst
Definition: gps6.h:144
gps6_cfg_setup
void gps6_cfg_setup(gps6_cfg_t *cfg)
GPS 6 configuration object setup function.
gps6_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: gps6.h:151
DRV_RX_BUFFER_SIZE
#define DRV_RX_BUFFER_SIZE
Definition: gps6.h:89
gps6_t::uart
uart_t uart
Definition: gps6.h:125
GPS6_ERROR
@ GPS6_ERROR
Definition: gps6.h:162
gps6_cfg_t::tx_pin
pin_name_t tx_pin
Definition: gps6.h:141
gps6_cfg_t::uart_blocking
bool uart_blocking
Definition: gps6.h:148
gps6_generic_write
err_t gps6_generic_write(gps6_t *ctx, char *data_buf, uint16_t len)
GPS 6 data writing function.
gps6_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: gps6.h:149
gps6_enable_device
void gps6_enable_device(gps6_t *ctx)
GPS 6 enable device function.
gps6_t
GPS 6 Click context object.
Definition: gps6.h:120
gps6_t::rst
digital_out_t rst
Definition: gps6.h:122
gps6_generic_read
err_t gps6_generic_read(gps6_t *ctx, char *data_buf, uint16_t max_len)
GPS 6 data reading function.
GPS6_OK
@ GPS6_OK
Definition: gps6.h:161
gps6_cfg_t::baud_rate
uint32_t baud_rate
Definition: gps6.h:147
DRV_TX_BUFFER_SIZE
#define DRV_TX_BUFFER_SIZE
GPS 6 driver buffer size.
Definition: gps6.h:88
gps6_cfg_t::rx_pin
pin_name_t rx_pin
Definition: gps6.h:140
gps6_parse_gpgga
err_t gps6_parse_gpgga(char *rsp_buf, uint8_t gpgga_element, char *element_data)
GPS 6 parse GPGGA function.
gps6_return_value_t
gps6_return_value_t
GPS 6 Click return value data.
Definition: gps6.h:160
gps6_init
err_t gps6_init(gps6_t *ctx, gps6_cfg_t *cfg)
GPS 6 initialization function.
gps6_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: gps6.h:150
gps6_cfg_t
GPS 6 Click configuration object.
Definition: gps6.h:138