irnss  2.0.0.0
irnss.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 IRNSS_H
29 #define IRNSS_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 
60 #define DRV_TX_BUFFER_SIZE 100
61 #define DRV_RX_BUFFER_SIZE 700
62  // irnss_set
64 
79 #define IRNSS_MAP_MIKROBUS( cfg, mikrobus ) \
80  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
81  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
82  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
83  cfg.wkp = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
84 
85  // irnss_map // irnss
87 
92 typedef struct
93 {
94  // Output pins
95  digital_out_t rst;
96  digital_out_t wkp;
98  // Modules
99  uart_t uart;
101  // Buffers
102  char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
103  char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
105 } irnss_t;
106 
111 typedef struct
112 {
113  // Communication gpio pins
114 
115  pin_name_t rx_pin;
116  pin_name_t tx_pin;
118  // Additional gpio pins
119  pin_name_t rst;
120  pin_name_t wkp;
122  // Static variable
123  uint32_t baud_rate;
124  bool uart_blocking;
125  uart_data_bits_t data_bit;
126  uart_parity_t parity_bit;
127  uart_stop_bits_t stop_bit;
129 } irnss_cfg_t;
130 
146 void irnss_cfg_setup ( irnss_cfg_t *cfg );
147 
162 err_t irnss_init ( irnss_t *ctx, irnss_cfg_t *cfg );
163 
177 err_t irnss_generic_write ( irnss_t *ctx, char *data_buf, uint16_t len );
178 
192 err_t irnss_generic_read ( irnss_t *ctx, char *data_buf, uint16_t max_len );
193 
204 void irnss_set_rst_pin_state ( irnss_t *ctx, uint8_t state );
205 
216 void irnss_set_wkp_pin_state ( irnss_t *ctx, uint8_t state );
217 
218 #ifdef __cplusplus
219 }
220 #endif
221 #endif // IRNSS_H
222  // irnss
224 
225 // ------------------------------------------------------------------------ END
irnss_cfg_setup
void irnss_cfg_setup(irnss_cfg_t *cfg)
IRNSS configuration object setup function.
DRV_RX_BUFFER_SIZE
#define DRV_RX_BUFFER_SIZE
Definition: irnss.h:60
irnss_set_rst_pin_state
void irnss_set_rst_pin_state(irnss_t *ctx, uint8_t state)
Sets state of the rst pin setting.
irnss_init
err_t irnss_init(irnss_t *ctx, irnss_cfg_t *cfg)
IRNSS initialization function.
irnss_generic_write
err_t irnss_generic_write(irnss_t *ctx, char *data_buf, uint16_t len)
IRNSS data writing function.
irnss_generic_read
err_t irnss_generic_read(irnss_t *ctx, char *data_buf, uint16_t max_len)
IRNSS data reading function.
irnss_t
IRNSS Click context object.
Definition: irnss.h:91
irnss_cfg_t
IRNSS Click configuration object.
Definition: irnss.h:110
DRV_TX_BUFFER_SIZE
#define DRV_TX_BUFFER_SIZE
IRNSS driver buffer size.
Definition: irnss.h:59
irnss_set_wkp_pin_state
void irnss_set_wkp_pin_state(irnss_t *ctx, uint8_t state)
Sets state of the wkp pin setting.