iqrf 2.0.0.0
iqrf.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 */
32// ----------------------------------------------------------------------------
33
34#ifndef IQRF_H
35#define IQRF_H
36
37#include "drv_digital_out.h"
38#include "drv_digital_in.h"
39#include "drv_uart.h"
40
41
42// -------------------------------------------------------------- PUBLIC MACROS
52#define IQRF_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
54 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
55 cfg.adc = MIKROBUS( mikrobus, MIKROBUS_AN ); \
56 cfg.io = MIKROBUS( mikrobus, MIKROBUS_RST ); \
57 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
58 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
59 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
66#define IQRF_RETVAL uint8_t
67
68#define IQRF_OK 0x00
69#define IQRF_INIT_ERROR 0xFF
76#define DRV_RX_BUFFER_SIZE 500 // End group macro
80
81// --------------------------------------------------------------- PUBLIC TYPES
91typedef struct
92{
93 // Output pins
94
95 digital_out_t io;
96 digital_out_t cs;
97 digital_out_t pwm;
98
99 // Input pins
100
101 digital_in_t adc;
102 digital_in_t int_pin;
103
104 // Modules
105
106 uart_t uart;
107
108 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
109 char uart_tx_buffer[ DRV_RX_BUFFER_SIZE ];
110
111} iqrf_t;
112
116typedef struct
117{
118 // Communication gpio pins
119
120 pin_name_t rx_pin;
121 pin_name_t tx_pin;
122
123 // Additional gpio pins
124
125 pin_name_t adc;
126 pin_name_t io;
127 pin_name_t cs;
128 pin_name_t pwm;
129 pin_name_t int_pin;
130
131 // Static variable
132
133 uint32_t baud_rate; // Clock speed.
135 uart_data_bits_t data_bit; // Data bits.
136 uart_parity_t parity_bit; // Parity bit.
137 uart_stop_bits_t stop_bit; // Stop bits.
138
139} iqrf_cfg_t;
140 // End types group
142
143// ------------------------------------------------------------------ CONSTANTS // End constants group
151
152// ------------------------------------------------------------------ VARIABLES // End variable group
160
161// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
162
168#ifdef __cplusplus
169extern "C"{
170#endif
171
181
190
205
215void iqrf_generic_multi_write ( iqrf_t *ctx, char *data_buf, uint8_t len );
216
226void iqrf_generic_multi_read ( iqrf_t *ctx, char *data_buf, uint8_t len );
227
237
246void iqrf_generic_single_write ( iqrf_t *ctx, char tx_data );
247
264uint8_t iqrf_get_interrupt ( iqrf_t *ctx );
265
273void iqrf_hw_reset ( iqrf_t *ctx );
274
275#ifdef __cplusplus
276}
277#endif
278#endif // _IQRF_H_
279 // End public_function group
282
283// ------------------------------------------------------------------------- END
#define DRV_RX_BUFFER_SIZE
Definition: iqrf.h:76
#define IQRF_RETVAL
Definition: iqrf.h:66
void iqrf_default_cfg(iqrf_t *ctx)
Click Default Configuration function.
void iqrf_cfg_setup(iqrf_cfg_t *cfg)
Config Object Initialization function.
void iqrf_generic_multi_write(iqrf_t *ctx, char *data_buf, uint8_t len)
Generic multi write function.
char iqrf_generic_single_read(iqrf_t *ctx)
Generic single read function.
void iqrf_generic_single_write(iqrf_t *ctx, char tx_data)
Generic single write function.
IQRF_RETVAL iqrf_init(iqrf_t *ctx, iqrf_cfg_t *cfg)
Initialization function.
uint8_t iqrf_get_interrupt(iqrf_t *ctx)
Interrupt function.
void iqrf_generic_multi_read(iqrf_t *ctx, char *data_buf, uint8_t len)
Generic multi read function.
void iqrf_hw_reset(iqrf_t *ctx)
Hardware reset function.
Click configuration structure definition.
Definition: iqrf.h:117
uint32_t baud_rate
Definition: iqrf.h:133
pin_name_t io
Definition: iqrf.h:126
pin_name_t adc
Definition: iqrf.h:125
bool uart_blocking
Definition: iqrf.h:134
uart_data_bits_t data_bit
Definition: iqrf.h:135
pin_name_t tx_pin
Definition: iqrf.h:121
pin_name_t rx_pin
Definition: iqrf.h:120
uart_stop_bits_t stop_bit
Definition: iqrf.h:137
pin_name_t int_pin
Definition: iqrf.h:129
pin_name_t pwm
Definition: iqrf.h:128
uart_parity_t parity_bit
Definition: iqrf.h:136
pin_name_t cs
Definition: iqrf.h:127
Click ctx object definition.
Definition: iqrf.h:92
digital_out_t cs
Definition: iqrf.h:96
digital_out_t pwm
Definition: iqrf.h:97
digital_out_t io
Definition: iqrf.h:95
uart_t uart
Definition: iqrf.h:106
digital_in_t int_pin
Definition: iqrf.h:102
digital_in_t adc
Definition: iqrf.h:101