mosaic  2.1.0.0
mosaic.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 MOSAIC_H
29 #define MOSAIC_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_uart.h"
48 
69 #define MOSAIC_CMD_SET_NMEA_OUTPUT "setNMEAOutput"
70 #define MOSAIC_CMD_GET_NMEA_VERSION "getNMEAVersion"
71 
76 #define MOSAIC_PROMPT_CMD "COM1>"
77 #define MOSAIC_PARAM_DELIMITER ","
78 #define MOSAIC_END_CMD "\r\n"
79 
84 #define MOSAIC_SNO_STREAM_1 "Stream1"
85 #define MOSAIC_SNO_STREAM_2 "Stream2"
86 #define MOSAIC_SNO_STREAM_3 "Stream3"
87 #define MOSAIC_SNO_STREAM_4 "Stream4"
88 #define MOSAIC_SNO_STREAM_5 "Stream5"
89 #define MOSAIC_SNO_STREAM_6 "Stream6"
90 #define MOSAIC_SNO_STREAM_7 "Stream7"
91 #define MOSAIC_SNO_STREAM_8 "Stream8"
92 #define MOSAIC_SNO_STREAM_9 "Stream9"
93 #define MOSAIC_SNO_STREAM_10 "Stream10"
94 #define MOSAIC_SNO_STREAM_ALL "all"
95 #define MOSAIC_SNO_CD_NONE "none"
96 #define MOSAIC_SNO_CD_COM1 "COM1"
97 #define MOSAIC_SNO_MESSAGES_NONE "none"
98 #define MOSAIC_SNO_MESSAGES_ALM "ALM"
99 #define MOSAIC_SNO_MESSAGES_DTM "DTM"
100 #define MOSAIC_SNO_MESSAGES_GBS "GBS"
101 #define MOSAIC_SNO_MESSAGES_GGA "GGA"
102 #define MOSAIC_SNO_MESSAGES_GLL "GLL"
103 #define MOSAIC_SNO_MESSAGES_GNS "GNS"
104 #define MOSAIC_SNO_MESSAGES_GRS "GRS"
105 #define MOSAIC_SNO_MESSAGES_GSA "GSA"
106 #define MOSAIC_SNO_MESSAGES_GST "GST"
107 #define MOSAIC_SNO_MESSAGES_GSV "GSV"
108 #define MOSAIC_SNO_MESSAGES_HDT "HDT"
109 #define MOSAIC_SNO_MESSAGES_RMC "RMC"
110 #define MOSAIC_SNO_MESSAGES_ROT "ROT"
111 #define MOSAIC_SNO_MESSAGES_VTG "VTG"
112 #define MOSAIC_SNO_MESSAGES_ZDA "ZDA"
113 #define MOSAIC_SNO_MESSAGES_HRP "HRP"
114 #define MOSAIC_SNO_MESSAGES_LLQ "LLQ"
115 #define MOSAIC_SNO_MESSAGES_RBP "RBP"
116 #define MOSAIC_SNO_MESSAGES_RBV "RBV"
117 #define MOSAIC_SNO_MESSAGES_RBD "RBD"
118 #define MOSAIC_SNO_MESSAGES_AVR "AVR"
119 #define MOSAIC_SNO_MESSAGES_GGK "GGK"
120 #define MOSAIC_SNO_MESSAGES_GFA "GFA"
121 #define MOSAIC_SNO_MESSAGES_GGQ "GGQ"
122 #define MOSAIC_SNO_MESSAGES_LLK "LLK"
123 #define MOSAIC_SNO_MESSAGES_GMP "GMP"
124 #define MOSAIC_SNO_MESSAGES_TXT_BASE "TXTbase"
125 #define MOSAIC_SNO_MESSAGES_TFM "TFM"
126 #define MOSAIC_SNO_MESSAGES_SNC "SNC"
127 #define MOSAIC_SNO_MESSAGES_THS "THS"
128 #define MOSAIC_SNO_INTERVAL_OFF "off"
129 #define MOSAIC_SNO_INTERVAL_ON_CHANGE "OnChange"
130 #define MOSAIC_SNO_INTERVAL_MSEC10 "msec10"
131 #define MOSAIC_SNO_INTERVAL_MSEC20 "msec20"
132 #define MOSAIC_SNO_INTERVAL_MSEC40 "msec40"
133 #define MOSAIC_SNO_INTERVAL_MSEC50 "msec50"
134 #define MOSAIC_SNO_INTERVAL_MSEC100 "msec100"
135 #define MOSAIC_SNO_INTERVAL_MSEC200 "msec200"
136 #define MOSAIC_SNO_INTERVAL_MSEC500 "msec500"
137 #define MOSAIC_SNO_INTERVAL_SEC1 "sec1"
138 #define MOSAIC_SNO_INTERVAL_SEC2 "sec2"
139 #define MOSAIC_SNO_INTERVAL_SEC5 "sec5"
140 #define MOSAIC_SNO_INTERVAL_SEC10 "sec10"
141 #define MOSAIC_SNO_INTERVAL_SEC15 "sec15"
142 #define MOSAIC_SNO_INTERVAL_SEC30 "sec30"
143 #define MOSAIC_SNO_INTERVAL_SEC60 "sec60"
144 #define MOSAIC_SNO_INTERVAL_MIN2 "min2"
145 #define MOSAIC_SNO_INTERVAL_MIN5 "min5"
146 #define MOSAIC_SNO_INTERVAL_MIN10 "min10"
147 #define MOSAIC_SNO_INTERVAL_MIN15 "min15"
148 #define MOSAIC_SNO_INTERVAL_MIN30 "min30"
149 #define MOSAIC_SNO_INTERVAL_MIN60 "min60"
150 
155 #define MOSAIC_NMEA_START "$"
156 #define MOSAIC_NMEA_DELIMITER ","
157 #define MOSAIC_NMEA_END "\r\n"
158 #define MOSAIC_NMEA_GGA "GGA"
159 
164 #define MOSAIC_GGA_ELEMENT_SIZE 15
165 #define MOSAIC_GGA_TIME 1
166 #define MOSAIC_GGA_LATITUDE 2
167 #define MOSAIC_GGA_LATITUDE_SIDE 3
168 #define MOSAIC_GGA_LONGITUDE 4
169 #define MOSAIC_GGA_LONGITUDE_SIDE 5
170 #define MOSAIC_GGA_QUALITY_INDICATOR 6
171 #define MOSAIC_GGA_NUMBER_OF_SATELLITES 7
172 #define MOSAIC_GGA_H_DILUTION_OF_POS 8
173 #define MOSAIC_GGA_ALTITUDE 9
174 #define MOSAIC_GGA_ALTITUDE_UNIT 10
175 #define MOSAIC_GGA_GEOIDAL_SEPARATION 11
176 #define MOSAIC_GGA_GEOIDAL_SEPARATION_UNIT 12
177 #define MOSAIC_GGA_TIME_SINCE_LAST_DGPS 13
178 #define MOSAIC_GGA_DGPS_REFERENCE_STATION_ID 14
179 
185 #define MOSAIC_RX_DRV_BUFFER_SIZE 400
186 #define MOSAIC_TX_DRV_BUFFER_SIZE 200
187  // mosaic_cmd
189 
204 #define MOSAIC_MAP_MIKROBUS( cfg, mikrobus ) \
205  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
206  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
207  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
208  cfg.cts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
209  cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
210  cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT );
211  // mosaic_map // mosaic
214 
219 typedef struct
220 {
221  // Output pins
222  digital_out_t rst;
223  digital_out_t cts;
225  // Input pins
226  digital_in_t rdy;
227  digital_in_t rts;
229  // Modules
230  uart_t uart;
232  // Buffers
233  uint8_t uart_rx_buffer[ MOSAIC_RX_DRV_BUFFER_SIZE ];
234  uint8_t uart_tx_buffer[ MOSAIC_TX_DRV_BUFFER_SIZE ];
236 } mosaic_t;
237 
242 typedef struct
243 {
244  // Communication gpio pins
245  pin_name_t rx_pin;
246  pin_name_t tx_pin;
248  // Additional gpio pins
249  pin_name_t rst;
250  pin_name_t cts;
251  pin_name_t rdy;
252  pin_name_t rts;
254  // Static variable
255  uint32_t baud_rate;
257  uart_data_bits_t data_bit;
258  uart_parity_t parity_bit;
259  uart_stop_bits_t stop_bit;
261 } mosaic_cfg_t;
262 
267 typedef enum
268 {
272 
274 
291 
305 err_t mosaic_init ( mosaic_t *ctx, mosaic_cfg_t *cfg );
306 
319 err_t mosaic_generic_write ( mosaic_t *ctx, uint8_t *data_in, uint16_t len );
320 
333 err_t mosaic_generic_read ( mosaic_t *ctx, uint8_t *data_out, uint16_t len );
334 
344 void mosaic_set_rst_pin ( mosaic_t *ctx, uint8_t state );
345 
355 void mosaic_set_cts_pin ( mosaic_t *ctx, uint8_t state );
356 
365 uint8_t mosaic_get_rdy_pin ( mosaic_t *ctx );
366 
375 uint8_t mosaic_get_rts_pin ( mosaic_t *ctx );
376 
386 void mosaic_send_cmd ( mosaic_t *ctx, uint8_t *cmd );
387 
398 void mosaic_send_cmd_with_par ( mosaic_t *ctx, uint8_t *cmd_buf, uint8_t *param_buf );
399 
410 void mosaic_enable_nmea_output ( mosaic_t *ctx, uint8_t *msg_param, uint8_t *interval );
411 
421 
433 err_t mosaic_parse_gga ( uint8_t *rsp_buf, uint8_t gga_element, uint8_t *element_data );
434 
435 #ifdef __cplusplus
436 }
437 #endif
438 #endif // MOSAIC_H
439  // mosaic
441 
442 // ------------------------------------------------------------------------ END
mosaic_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: mosaic.h:259
mosaic_generic_write
err_t mosaic_generic_write(mosaic_t *ctx, uint8_t *data_in, uint16_t len)
Mosaic data writing function.
mosaic_cfg_t
Mosaic Click configuration object.
Definition: mosaic.h:243
mosaic_t::uart
uart_t uart
Definition: mosaic.h:230
mosaic_cfg_t::rx_pin
pin_name_t rx_pin
Definition: mosaic.h:245
MOSAIC_ERROR
@ MOSAIC_ERROR
Definition: mosaic.h:270
mosaic_disable_nmea_output
void mosaic_disable_nmea_output(mosaic_t *ctx)
Mosaic disable nmea output function.
mosaic_cfg_t::rst
pin_name_t rst
Definition: mosaic.h:249
mosaic_generic_read
err_t mosaic_generic_read(mosaic_t *ctx, uint8_t *data_out, uint16_t len)
Mosaic data reading function.
mosaic_cfg_t::tx_pin
pin_name_t tx_pin
Definition: mosaic.h:246
mosaic_t::cts
digital_out_t cts
Definition: mosaic.h:223
mosaic_cfg_t::rdy
pin_name_t rdy
Definition: mosaic.h:251
mosaic_cfg_t::baud_rate
uint32_t baud_rate
Definition: mosaic.h:255
mosaic_cfg_t::uart_blocking
bool uart_blocking
Definition: mosaic.h:256
mosaic_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: mosaic.h:257
mosaic_cfg_setup
void mosaic_cfg_setup(mosaic_cfg_t *cfg)
Mosaic configuration object setup function.
mosaic_init
err_t mosaic_init(mosaic_t *ctx, mosaic_cfg_t *cfg)
Mosaic initialization function.
mosaic_set_cts_pin
void mosaic_set_cts_pin(mosaic_t *ctx, uint8_t state)
Mosaic set cts pin function.
MOSAIC_TX_DRV_BUFFER_SIZE
#define MOSAIC_TX_DRV_BUFFER_SIZE
Definition: mosaic.h:186
mosaic_set_rst_pin
void mosaic_set_rst_pin(mosaic_t *ctx, uint8_t state)
Mosaic set rst pin function.
mosaic_get_rts_pin
uint8_t mosaic_get_rts_pin(mosaic_t *ctx)
Mosaic get rts pin function.
mosaic_cfg_t::rts
pin_name_t rts
Definition: mosaic.h:252
mosaic_send_cmd
void mosaic_send_cmd(mosaic_t *ctx, uint8_t *cmd)
Send command function.
mosaic_t::rst
digital_out_t rst
Definition: mosaic.h:222
mosaic_enable_nmea_output
void mosaic_enable_nmea_output(mosaic_t *ctx, uint8_t *msg_param, uint8_t *interval)
Mosaic enable nmea output function.
MOSAIC_ERROR_TIMEOUT
@ MOSAIC_ERROR_TIMEOUT
Definition: mosaic.h:271
MOSAIC_RX_DRV_BUFFER_SIZE
#define MOSAIC_RX_DRV_BUFFER_SIZE
Mosaic driver buffer size.
Definition: mosaic.h:185
mosaic_get_rdy_pin
uint8_t mosaic_get_rdy_pin(mosaic_t *ctx)
Mosaic get rdy pin function.
mosaic_return_value_t
mosaic_return_value_t
Mosaic Click return value data.
Definition: mosaic.h:268
mosaic_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: mosaic.h:258
mosaic_send_cmd_with_par
void mosaic_send_cmd_with_par(mosaic_t *ctx, uint8_t *cmd_buf, uint8_t *param_buf)
Send command function with parameter.
mosaic_parse_gga
err_t mosaic_parse_gga(uint8_t *rsp_buf, uint8_t gga_element, uint8_t *element_data)
Mosaic parse GGA function.
mosaic_t::rts
digital_in_t rts
Definition: mosaic.h:227
mosaic_t
Mosaic Click context object.
Definition: mosaic.h:220
MOSAIC_OK
@ MOSAIC_OK
Definition: mosaic.h:269
mosaic_cfg_t::cts
pin_name_t cts
Definition: mosaic.h:250
mosaic_t::rdy
digital_in_t rdy
Definition: mosaic.h:226