ookrx 2.1.0.0
ookrx.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 OOKRX_H
29#define OOKRX_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_analog_in.h"
52
73#define OOKRX_RSSI_VREF_3V3 3.3f
74#define OOKRX_RSSI_MIN_DBM ( -110 )
75#define OOKRX_RSSI_MAX_DBM ( -50 )
76#define OOKRX_RSSI_RANGE_DBM ( OOKRX_RSSI_MAX_DBM - OOKRX_RSSI_MIN_DBM )
77#define OOKRX_RSSI_MIN_V 0.4f
78#define OOKRX_RSSI_MAX_V 2.06f
79#define OOKRX_RSSI_RANGE_V ( OOKRX_RSSI_MAX_V - OOKRX_RSSI_MIN_V )
80#define OOKRX_RSSI_DBM_PER_V ( OOKRX_RSSI_RANGE_DBM / OOKRX_RSSI_MAX_V )
81#define OOKRX_RSSI_V_TO_DBM(x) ( OOKRX_RSSI_MIN_DBM + ( ( x - OOKRX_RSSI_MIN_V ) * OOKRX_RSSI_DBM_PER_V ) )
82#define OOKRX_MAN_BIT_LEN_US 2000
83#define OOKRX_MAX_DATA_LEN 255
84
85 // ookrx_cfg
86
101#define OOKRX_MAP_MIKROBUS( cfg, mikrobus ) \
102 cfg.rssi = MIKROBUS( mikrobus, MIKROBUS_AN ); \
103 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
104 cfg.sqc = MIKROBUS( mikrobus, MIKROBUS_CS ); \
105 cfg.dout = MIKROBUS( mikrobus, MIKROBUS_INT )
106
107 // ookrx_map
108 // ookrx
109
114typedef struct
115{
116 digital_out_t en;
117 digital_out_t sqc;
119 digital_in_t dout;
121 analog_in_t adc;
123} ookrx_t;
124
129typedef struct
130{
131 pin_name_t rssi;
132 pin_name_t en;
133 pin_name_t sqc;
134 pin_name_t dout;
136 analog_in_resolution_t resolution;
137 float vref;
140
145typedef enum
146{
148 OOKRX_ERROR = -1
149
151
168
182err_t ookrx_init ( ookrx_t *ctx, ookrx_cfg_t *cfg );
183
193
203
213
223
233
247err_t ookrx_read_rssi_voltage ( ookrx_t *ctx, float *data_out );
248
249#ifdef __cplusplus
250}
251#endif
252#endif // OOKRX_H
253
254 // ookrx
255
256// ------------------------------------------------------------------------ END
err_t ookrx_read_rssi_voltage(ookrx_t *ctx, float *data_out)
OOK RX read RSSI pin voltage level function.
void ookrx_disable_squelch(ookrx_t *ctx)
OOK RX disable squelch function.
void ookrx_enable_squelch(ookrx_t *ctx)
OOK RX enable squelch function.
void ookrx_enable_device(ookrx_t *ctx)
OOK RX enable device function.
err_t ookrx_init(ookrx_t *ctx, ookrx_cfg_t *cfg)
OOK RX initialization function.
void ookrx_disable_device(ookrx_t *ctx)
OOK RX disable device function.
uint8_t ookrx_get_data_pin(ookrx_t *ctx)
OOK RX get data pin function.
void ookrx_cfg_setup(ookrx_cfg_t *cfg)
OOK RX configuration object setup function.
ookrx_return_value_t
OOK RX Click return value data.
Definition ookrx.h:146
@ OOKRX_ERROR
Definition ookrx.h:148
@ OOKRX_OK
Definition ookrx.h:147
OOK RX Click configuration object.
Definition ookrx.h:130
analog_in_resolution_t resolution
Definition ookrx.h:136
float vref
Definition ookrx.h:137
pin_name_t rssi
Definition ookrx.h:131
pin_name_t dout
Definition ookrx.h:134
pin_name_t sqc
Definition ookrx.h:133
pin_name_t en
Definition ookrx.h:132
OOK RX Click context object.
Definition ookrx.h:115
digital_in_t dout
Definition ookrx.h:119
digital_out_t sqc
Definition ookrx.h:117
digital_out_t en
Definition ookrx.h:116
analog_in_t adc
Definition ookrx.h:121