ismrx3 2.0.0.0
ismrx3.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 ISMRX3_H
29#define ISMRX3_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_spi_master.h"
52
73#define ISMRX3_DEMOD 0x00
74#define ISMRX3_AGC 0x01
75#define ISMRX3_IF_CHF_SEL 0x02
76#define ISMRX3_PDF_CFG 0x03
77#define ISMRX3_ATH_CFG_1 0x04
78#define ISMRX3_ATH_CFG_2 0x05
79#define ISMRX3_ATH_CFG_3 0x06
80#define ISMRX3_AFC_CFG_1 0x07
81#define ISMRX3_AFC_CFG_2 0x08
82#define ISMRX3_LO_CTR_FREQ_3 0x09
83#define ISMRX3_LO_CTR_FREQ_2 0x0A
84#define ISMRX3_LO_CTR_FREQ_1 0x0B
85#define ISMRX3_PREAMBLE_CFG_1 0x0C
86#define ISMRX3_PREAMBLE_WORD_1 0x0D
87#define ISMRX3_PREAMBLE_WROD_2 0x0E
88#define ISMRX3_RSS 0x10
89#define ISMRX3_FEI 0x11
90#define ISMRX3_PDF_OUT 0x12
91#define ISMRX3_ISR 0x13
92#define ISMRX3_CDR_CFG 0x35
93#define ISMRX3_STATE_CTRL_1 0x14
94#define ISMRX3_STATE_CTRL_2 0x15
95#define ISMRX3_STATE_CTRL_3 0x16
96#define ISMRX3_WUT_1 0x17
97#define ISMRX3_WUT_2 0x18
98#define ISMRX3_AFE_CTL_1 0x19
99#define ISMRX3_IR_ADJUST 0x1A
100#define ISMRX3_PART_NUM 0x1E
101#define ISMRX3_REV_NUM 0x1F
102#define ISMRX3_STATUS 0x27
103
104 // ismrx3_reg
105
120#define ISMRX3_MODULATION_ASK 0x01
121#define ISMRX3_MODULATION_FSK 0x02
122
127#define ISMRX3_FREQUENCY_MHZ_315 0x01
128#define ISMRX3_FREQUENCY_MHZ_433p92 0x02
129#define ISMRX3_FREQUENCY_MHZ_868p3 0x03
130
135#define ISMRX3_DEVIATION_KHZ_5 0x01
136#define ISMRX3_DEVIATION_KHZ_10 0x02
137#define ISMRX3_DEVIATION_KHZ_40 0x03
138#define ISMRX3_DEVIATION_KHZ_80 0x04
139
144#define ISMRX3_DATA_RATE_KBPS_1 0x01
145#define ISMRX3_DATA_RATE_KBPS_2 0x02
146#define ISMRX3_DATA_RATE_KBPS_5 0x03
147#define ISMRX3_DATA_RATE_KBPS_10 0x04
148#define ISMRX3_DATA_RATE_KBPS_50 0x05
149#define ISMRX3_DATA_RATE_KBPS_100 0x06
150
151 // ismrx3_set
152
167#define ISMRX3_MAP_MIKROBUS( cfg, mikrobus ) \
168 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
169 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
170 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
171 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
172 cfg.dat = MIKROBUS( mikrobus, MIKROBUS_AN ); \
173 cfg.pdn = MIKROBUS( mikrobus, MIKROBUS_RST ); \
174 cfg.sw = MIKROBUS( mikrobus, MIKROBUS_PWM );\
175 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
176
177 // ismrx3_map
178 // ismrx3
179
184typedef struct
185{
186 // Output pins
187 digital_out_t pdn;
188 digital_out_t sw;
190 // Input pins
191 digital_in_t dat;
192 digital_in_t int_pin;
194 // Modules
195 spi_master_t spi;
196 pin_name_t chip_select;
198 uint8_t modulation;
201 uint8_t data_rate;
202} ismrx3_t;
203
208typedef struct
209{
210 // Communication gpio pins
211 pin_name_t miso;
212 pin_name_t mosi;
213 pin_name_t sck;
214 pin_name_t cs;
216 // Additional gpio pins
217 pin_name_t dat;
218 pin_name_t pdn;
219 pin_name_t sw;
220 pin_name_t int_pin;
222 // static variable
223 uint32_t spi_speed;
224 spi_master_mode_t spi_mode;
225 spi_master_chip_select_polarity_t cs_polarity;
228
240
257
271err_t ismrx3_init ( ismrx3_t *ctx, ismrx3_cfg_t *cfg );
272
287
300err_t ismrx3_generic_write ( ismrx3_t *ctx, uint8_t reg, uint8_t data_in );
301
314err_t ismrx3_generic_read ( ismrx3_t *ctx, uint8_t reg, uint8_t *data_out );
315
324
332uint8_t ismrx3_get_clk( ismrx3_t *ctx );
333
341uint8_t ismrx3_get_data( ismrx3_t *ctx );
342
343#ifdef __cplusplus
344}
345#endif
346#endif // ISMRX3_H
347
348 // ismrx3
349
350// ------------------------------------------------------------------------ END
err_t ismrx3_init(ismrx3_t *ctx, ismrx3_cfg_t *cfg)
ISM RX 3 initialization function.
err_t ismrx3_generic_write(ismrx3_t *ctx, uint8_t reg, uint8_t data_in)
ISM RX 3 data writing function.
uint8_t ismrx3_get_clk(ismrx3_t *ctx)
Read clock output.
uint8_t ismrx3_get_data(ismrx3_t *ctx)
Read data output.
void ismrx3_cfg_setup(ismrx3_cfg_t *cfg)
ISM RX 3 configuration object setup function.
err_t ismrx3_default_cfg(ismrx3_t *ctx)
ISM RX 3 default configuration function.
err_t ismrx3_generic_read(ismrx3_t *ctx, uint8_t reg, uint8_t *data_out)
ISM RX 3 data reading function.
void ismrx3_reset(ismrx3_t *ctx)
Reset function.
ismrx3_return_value_t
ISM RX 3 Click return value data.
Definition ismrx3.h:234
@ ISMRX3_ERROR_BUF_LEN
Definition ismrx3.h:237
@ ISMRX3_OK
Definition ismrx3.h:235
@ ISMRX3_ERROR
Definition ismrx3.h:236
ISM RX 3 Click configuration object.
Definition ismrx3.h:209
spi_master_chip_select_polarity_t cs_polarity
Definition ismrx3.h:225
pin_name_t sck
Definition ismrx3.h:213
spi_master_mode_t spi_mode
Definition ismrx3.h:224
pin_name_t pdn
Definition ismrx3.h:218
pin_name_t mosi
Definition ismrx3.h:212
uint32_t spi_speed
Definition ismrx3.h:223
pin_name_t int_pin
Definition ismrx3.h:220
pin_name_t dat
Definition ismrx3.h:217
pin_name_t sw
Definition ismrx3.h:219
pin_name_t miso
Definition ismrx3.h:211
pin_name_t cs
Definition ismrx3.h:214
ISM RX 3 Click context object.
Definition ismrx3.h:185
uint8_t reference_freq
Definition ismrx3.h:199
spi_master_t spi
Definition ismrx3.h:195
uint8_t modulation
Definition ismrx3.h:198
digital_out_t sw
Definition ismrx3.h:188
digital_out_t pdn
Definition ismrx3.h:187
digital_in_t dat
Definition ismrx3.h:191
digital_in_t int_pin
Definition ismrx3.h:192
uint8_t data_rate
Definition ismrx3.h:201
uint8_t freq_deviation
Definition ismrx3.h:200
pin_name_t chip_select
Definition ismrx3.h:196