rtkbase 2.1.0.0
rtkbase.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 RTKBASE_H
29#define RTKBASE_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
74#define TX_DRV_BUFFER_SIZE 100
75#define RX_DRV_BUFFER_SIZE 1000
76
77 // rtkbase_cmd
78
93#define RTKBASE_MAP_MIKROBUS( cfg, mikrobus ) \
94 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
95 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
96 cfg.shd = MIKROBUS( mikrobus, MIKROBUS_AN ); \
97 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
98 cfg.wup = MIKROBUS( mikrobus, MIKROBUS_CS ); \
99 cfg.bt = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
100 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
101
102 // rtkbase_map
103 // rtkbase
104
109typedef struct
110{
111 // Output pins
112 digital_out_t shd;
113 digital_out_t rst;
114 digital_out_t wup;
115 digital_out_t bt;
117 // Input pins
118 digital_in_t int_pin;
120 // Modules
121 uart_t uart;
123 // Buffers
124 char uart_rx_buffer[ RX_DRV_BUFFER_SIZE ];
125 char uart_tx_buffer[ TX_DRV_BUFFER_SIZE ];
127} rtkbase_t;
128
133typedef struct
134{
135 // Communication gpio pins
136 pin_name_t rx_pin;
137 pin_name_t tx_pin;
139 // Additional gpio pins
140 pin_name_t shd;
141 pin_name_t rst;
142 pin_name_t wup;
143 pin_name_t bt;
144 pin_name_t int_pin;
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;
154
159typedef enum
160{
162 RTKBASE_ERROR = -1
163
165
182
197
210err_t rtkbase_generic_write ( rtkbase_t *ctx, char *data_in, uint16_t len );
211
224err_t rtkbase_generic_read ( rtkbase_t *ctx, char *data_out, uint16_t len );
225
235
245
255
265void rtkbase_set_rst_pin ( rtkbase_t *ctx, uint8_t state );
266
276void rtkbase_set_wup_pin ( rtkbase_t *ctx, uint8_t state );
277
287void rtkbase_set_boot_pin ( rtkbase_t *ctx, uint8_t state );
288
298void rtkbase_set_shd_pin ( rtkbase_t *ctx, uint8_t state );
299
309
319uint32_t rtkbase_calculate_crc24( uint8_t *data_buf, uint16_t data_len );
320
321#ifdef __cplusplus
322}
323#endif
324#endif // RTKBASE_H
325
326 // rtkbase
327
328// ------------------------------------------------------------------------ END
#define RX_DRV_BUFFER_SIZE
Definition rtkbase.h:75
#define TX_DRV_BUFFER_SIZE
RTK Base driver buffer size.
Definition rtkbase.h:74
err_t rtkbase_generic_write(rtkbase_t *ctx, char *data_in, uint16_t len)
RTK Base data writing function.
uint32_t rtkbase_calculate_crc24(uint8_t *data_buf, uint16_t data_len)
RTK Base calculate crc24 function.
void rtkbase_set_boot_pin(rtkbase_t *ctx, uint8_t state)
RTK Base set BOOT pin function.
void rtkbase_set_wup_pin(rtkbase_t *ctx, uint8_t state)
RTK Base set WUP pin function.
void rtkbase_enable_rx_interrupt(rtkbase_t *ctx)
RTK Base enable rx interrupt function.
void rtkbase_set_rst_pin(rtkbase_t *ctx, uint8_t state)
RTK Base set RST pin function.
uint8_t rtkbase_get_int_pin(rtkbase_t *ctx)
RTK Base get INT pin function.
void rtkbase_cfg_setup(rtkbase_cfg_t *cfg)
RTK Base configuration object setup function.
void rtkbase_clear_ring_buffers(rtkbase_t *ctx)
RTK Base clear ring buffers function.
err_t rtkbase_init(rtkbase_t *ctx, rtkbase_cfg_t *cfg)
RTK Base initialization function.
void rtkbase_set_shd_pin(rtkbase_t *ctx, uint8_t state)
RTK Base set SHD pin function.
err_t rtkbase_rx_bytes_available(rtkbase_t *ctx)
RTK Base rx bytes available function.
err_t rtkbase_generic_read(rtkbase_t *ctx, char *data_out, uint16_t len)
RTK Base data reading function.
rtkbase_return_value_t
RTK Base Click return value data.
Definition rtkbase.h:160
@ RTKBASE_OK
Definition rtkbase.h:161
@ RTKBASE_ERROR
Definition rtkbase.h:162
RTK Base Click configuration object.
Definition rtkbase.h:134
uint32_t baud_rate
Definition rtkbase.h:147
pin_name_t wup
Definition rtkbase.h:142
pin_name_t bt
Definition rtkbase.h:143
bool uart_blocking
Definition rtkbase.h:148
uart_data_bits_t data_bit
Definition rtkbase.h:149
pin_name_t tx_pin
Definition rtkbase.h:137
pin_name_t rx_pin
Definition rtkbase.h:136
pin_name_t shd
Definition rtkbase.h:140
uart_stop_bits_t stop_bit
Definition rtkbase.h:151
pin_name_t int_pin
Definition rtkbase.h:144
uart_parity_t parity_bit
Definition rtkbase.h:150
pin_name_t rst
Definition rtkbase.h:141
RTK Base Click context object.
Definition rtkbase.h:110
uart_t uart
Definition rtkbase.h:121
digital_in_t int_pin
Definition rtkbase.h:118
digital_out_t wup
Definition rtkbase.h:114
digital_out_t rst
Definition rtkbase.h:113
digital_out_t bt
Definition rtkbase.h:115
digital_out_t shd
Definition rtkbase.h:112