gnsszoe  2.0.0.0
gnsszoe.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef GNSSZOE_H
36 #define GNSSZOE_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
54 #define GNSSZOE_MAP_MIKROBUS( cfg, mikrobus ) \
55  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
56  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
57  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
58  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
59  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
60  cfg.exi = MIKROBUS( mikrobus, MIKROBUS_PWM )
61 
67 #define GNSSZOE_RETVAL uint8_t
68 
69 #define GNSSZOE_OK 0x00
70 #define GNSSZOE_INIT_ERROR 0xFF
71 
77 #define GNSSZOE_NEMA_GNGGA 1
78 #define GNSSZOE_NEMA_GNGLL 3
79 #define GNSSZOE_NEMA_GNGGA_NUM_ELEMENT 15
80 #define GNSSZOE_NEMA_GNGLL_NUM_ELEMENT 5
81 
87 #define GNSSZOE_GNGGA_TIME 1
88 #define GNSSZOE_GNGGA_LATITUDE 2
89 #define GNSSZOE_GNGGA_LATITUDE_SIDE 3
90 #define GNSSZOE_GNGGA_LONGITUDE 4
91 #define GNSSZOE_GNGGA_LONGITUDE_SIDE 5
92 #define GNSSZOE_GNGGA_QUALITY_INDICATOR 6
93 #define GNSSZOE_GNGGA_NUMBER_OF_SATELLITES 7
94 #define GNSSZOE_GNGGA_H_DILUTION_OF_POS 8
95 #define GNSSZOE_GNGGA_ALTITUDE 9
96 #define GNSSZOE_GNGGA_ALTITUDE_UNIT 10
97 #define GNSSZOE_GNGGA_GEOIDAL_SEPARATION 11
98 #define GNSSZOE_GNGGA_GEOIDAL_SEPARATION_UNIT 12
99 #define GNSSZOE_GNGGA_TIME_SINCE_LAST_DGPS 13
100 #define GNSSZOE_GNGGA_DGPS_REFERENCE_STATION_ID 14
101 
107 #define GNSSZOE_GNGLL_LATITUDE 1
108 #define GNSSZOE_GNGLL_LATITUDE_SIDE 2
109 #define GNSSZOE_GNGLL_LONGITUDE 3
110 #define GNSSZOE_GNGLL_LONGITUDE_SIDE 4
111 
117 #define GNSSZOE_ERROR_COMMAND_OR_ELEMENT 0xFF
118 #define GNSSZOE_ERROR_START_OR_END_COMMAND 0x8F
119 #define GNSSZOE_ERROR_NEXT_ELEMENT 0x4F
120 #define GNSSZOE_ERROR_CURRENT_ELEMENT 0x2F
121 #define GNSSZOE_NO_ERROR 0x00
122 
128 #define DRV_RX_BUFFER_SIZE 500
129  // End group macro
131 // --------------------------------------------------------------- PUBLIC TYPES
140 typedef struct
141 {
142  digital_out_t cs;
143  // Output pins
144 
145  digital_out_t rst;
146  digital_out_t exi;
147 
148  // Modules
149 
150  spi_master_t spi;
151  pin_name_t chip_select;
152 
153 } gnsszoe_t;
154 
158 typedef struct
159 {
160  // Communication gpio pins
161 
162  pin_name_t miso;
163  pin_name_t mosi;
164  pin_name_t sck;
165  pin_name_t cs;
166 
167  // Additional gpio pins
168 
169  pin_name_t rst;
170  pin_name_t exi;
171 
172  // static variable
173 
174  uint32_t spi_speed;
175  spi_master_mode_t spi_mode;
176  spi_master_chip_select_polarity_t cs_polarity;
177 
178 
179 } gnsszoe_cfg_t;
180 
184 typedef uint8_t gnsszoe_error_t;
185  // End types group
187 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
188 
193 #ifdef __cplusplus
194 extern "C"{
195 #endif
196 
205 void gnsszoe_cfg_setup ( gnsszoe_cfg_t *cfg );
206 
215 
225 (
226  gnsszoe_t *ctx,
227  uint8_t *wr_buf,
228  uint16_t wr_len,
229  uint8_t *rd_buf,
230  uint16_t rd_len
231 );
232 
242 (
243  char *rsp, uint8_t command,
244  uint8_t element, char *parser_buf
245 );
246 
255 void gnsszoe_generic_read ( gnsszoe_t *ctx, uint8_t *rd_buf, uint16_t rd_len );
256 
261 void gnsszoe_module_reset ( gnsszoe_t *ctx );
262 
263 #ifdef __cplusplus
264 }
265 #endif
266 #endif // _GNSSZOE_H_
267  // End public_function group
270 
271 // ------------------------------------------------------------------------- END
gnsszoe_cfg_t::mosi
pin_name_t mosi
Definition: gnsszoe.h:163
gnsszoe_t
Click ctx object definition.
Definition: gnsszoe.h:140
gnsszoe_generic_parser
gnsszoe_error_t gnsszoe_generic_parser(char *rsp, uint8_t command, uint8_t element, char *parser_buf)
Generic parser function.
gnsszoe_t::cs
digital_out_t cs
Definition: gnsszoe.h:142
gnsszoe_cfg_setup
void gnsszoe_cfg_setup(gnsszoe_cfg_t *cfg)
Config Object Initialization function.
gnsszoe_cfg_t::rst
pin_name_t rst
Definition: gnsszoe.h:169
gnsszoe_t::rst
digital_out_t rst
Definition: gnsszoe.h:145
gnsszoe_generic_read
void gnsszoe_generic_read(gnsszoe_t *ctx, uint8_t *rd_buf, uint16_t rd_len)
Generic read function.
gnsszoe_t::exi
digital_out_t exi
Definition: gnsszoe.h:146
gnsszoe_cfg_t
Click configuration structure definition.
Definition: gnsszoe.h:158
gnsszoe_cfg_t::exi
pin_name_t exi
Definition: gnsszoe.h:170
gnsszoe_cfg_t::cs
pin_name_t cs
Definition: gnsszoe.h:165
gnsszoe_cfg_t::spi_speed
uint32_t spi_speed
Definition: gnsszoe.h:174
gnsszoe_t::spi
spi_master_t spi
Definition: gnsszoe.h:150
GNSSZOE_RETVAL
#define GNSSZOE_RETVAL
Definition: gnsszoe.h:67
gnsszoe_cfg_t::sck
pin_name_t sck
Definition: gnsszoe.h:164
gnsszoe_error_t
uint8_t gnsszoe_error_t
Error type.
Definition: gnsszoe.h:184
gnsszoe_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: gnsszoe.h:176
gnsszoe_t::chip_select
pin_name_t chip_select
Definition: gnsszoe.h:151
gnsszoe_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: gnsszoe.h:175
gnsszoe_generic_transfer
void gnsszoe_generic_transfer(gnsszoe_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
gnsszoe_module_reset
void gnsszoe_module_reset(gnsszoe_t *ctx)
Reset module.
gnsszoe_init
GNSSZOE_RETVAL gnsszoe_init(gnsszoe_t *ctx, gnsszoe_cfg_t *cfg)
Initialization function.
gnsszoe_cfg_t::miso
pin_name_t miso
Definition: gnsszoe.h:162