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
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_spi_master.h"
38 
59 #define ISMRX3_DEMOD 0x00
60 #define ISMRX3_AGC 0x01
61 #define ISMRX3_IF_CHF_SEL 0x02
62 #define ISMRX3_PDF_CFG 0x03
63 #define ISMRX3_ATH_CFG_1 0x04
64 #define ISMRX3_ATH_CFG_2 0x05
65 #define ISMRX3_ATH_CFG_3 0x06
66 #define ISMRX3_AFC_CFG_1 0x07
67 #define ISMRX3_AFC_CFG_2 0x08
68 #define ISMRX3_LO_CTR_FREQ_3 0x09
69 #define ISMRX3_LO_CTR_FREQ_2 0x0A
70 #define ISMRX3_LO_CTR_FREQ_1 0x0B
71 #define ISMRX3_PREAMBLE_CFG_1 0x0C
72 #define ISMRX3_PREAMBLE_WORD_1 0x0D
73 #define ISMRX3_PREAMBLE_WROD_2 0x0E
74 #define ISMRX3_RSS 0x10
75 #define ISMRX3_FEI 0x11
76 #define ISMRX3_PDF_OUT 0x12
77 #define ISMRX3_ISR 0x13
78 #define ISMRX3_CDR_CFG 0x35
79 #define ISMRX3_STATE_CTRL_1 0x14
80 #define ISMRX3_STATE_CTRL_2 0x15
81 #define ISMRX3_STATE_CTRL_3 0x16
82 #define ISMRX3_WUT_1 0x17
83 #define ISMRX3_WUT_2 0x18
84 #define ISMRX3_AFE_CTL_1 0x19
85 #define ISMRX3_IR_ADJUST 0x1A
86 #define ISMRX3_PART_NUM 0x1E
87 #define ISMRX3_REV_NUM 0x1F
88 #define ISMRX3_STATUS 0x27
89  // ismrx3_reg
91 
106 #define ISMRX3_MODULATION_ASK 0x01
107 #define ISMRX3_MODULATION_FSK 0x02
108 
113 #define ISMRX3_FREQUENCY_MHZ_315 0x01
114 #define ISMRX3_FREQUENCY_MHZ_433p92 0x02
115 #define ISMRX3_FREQUENCY_MHZ_868p3 0x03
116 
121 #define ISMRX3_DEVIATION_KHZ_5 0x01
122 #define ISMRX3_DEVIATION_KHZ_10 0x02
123 #define ISMRX3_DEVIATION_KHZ_40 0x03
124 #define ISMRX3_DEVIATION_KHZ_80 0x04
125 
130 #define ISMRX3_DATA_RATE_KBPS_1 0x01
131 #define ISMRX3_DATA_RATE_KBPS_2 0x02
132 #define ISMRX3_DATA_RATE_KBPS_5 0x03
133 #define ISMRX3_DATA_RATE_KBPS_10 0x04
134 #define ISMRX3_DATA_RATE_KBPS_50 0x05
135 #define ISMRX3_DATA_RATE_KBPS_100 0x06
136  // ismrx3_set
138 
153 #define ISMRX3_MAP_MIKROBUS( cfg, mikrobus ) \
154  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
155  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
156  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
157  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
158  cfg.dat = MIKROBUS( mikrobus, MIKROBUS_AN ); \
159  cfg.pdn = MIKROBUS( mikrobus, MIKROBUS_RST ); \
160  cfg.sw = MIKROBUS( mikrobus, MIKROBUS_PWM );\
161  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
162  // ismrx3_map // ismrx3
165 
170 typedef struct
171 {
172  // Output pins
173  digital_out_t pdn;
174  digital_out_t sw;
176  // Input pins
177  digital_in_t dat;
178  digital_in_t int_pin;
180  // Modules
181  spi_master_t spi;
182  pin_name_t chip_select;
184  uint8_t modulation;
185  uint8_t reference_freq;
186  uint8_t freq_deviation;
187  uint8_t data_rate;
188 } ismrx3_t;
189 
194 typedef struct
195 {
196  // Communication gpio pins
197  pin_name_t miso;
198  pin_name_t mosi;
199  pin_name_t sck;
200  pin_name_t cs;
202  // Additional gpio pins
203  pin_name_t dat;
204  pin_name_t pdn;
205  pin_name_t sw;
206  pin_name_t int_pin;
208  // static variable
209  uint32_t spi_speed;
210  spi_master_mode_t spi_mode;
211  spi_master_chip_select_polarity_t cs_polarity;
213 } ismrx3_cfg_t;
214 
219 typedef enum
220 {
224 
226 
243 
257 err_t ismrx3_init ( ismrx3_t *ctx, ismrx3_cfg_t *cfg );
258 
273 
286 err_t ismrx3_generic_write ( ismrx3_t *ctx, uint8_t reg, uint8_t data_in );
287 
300 err_t ismrx3_generic_read ( ismrx3_t *ctx, uint8_t reg, uint8_t *data_out );
301 
309 void ismrx3_reset( ismrx3_t *ctx );
310 
318 uint8_t ismrx3_get_clk( ismrx3_t *ctx );
319 
327 uint8_t ismrx3_get_data( ismrx3_t *ctx );
328 
329 #ifdef __cplusplus
330 }
331 #endif
332 #endif // ISMRX3_H
333  // ismrx3
335 
336 // ------------------------------------------------------------------------ END
ismrx3_init
err_t ismrx3_init(ismrx3_t *ctx, ismrx3_cfg_t *cfg)
ISM RX 3 initialization function.
ismrx3_t::chip_select
pin_name_t chip_select
Definition: ismrx3.h:182
ismrx3_reset
void ismrx3_reset(ismrx3_t *ctx)
Reset function.
ismrx3_cfg_t::int_pin
pin_name_t int_pin
Definition: ismrx3.h:206
ismrx3_t::spi
spi_master_t spi
Definition: ismrx3.h:181
ismrx3_get_data
uint8_t ismrx3_get_data(ismrx3_t *ctx)
Read data output.
ISMRX3_OK
@ ISMRX3_OK
Definition: ismrx3.h:221
ismrx3_cfg_t::cs
pin_name_t cs
Definition: ismrx3.h:200
ismrx3_cfg_t::sw
pin_name_t sw
Definition: ismrx3.h:205
ISMRX3_ERROR
@ ISMRX3_ERROR
Definition: ismrx3.h:222
ismrx3_cfg_t::mosi
pin_name_t mosi
Definition: ismrx3.h:198
ismrx3_cfg_t::sck
pin_name_t sck
Definition: ismrx3.h:199
ismrx3_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: ismrx3.h:211
ismrx3_t::data_rate
uint8_t data_rate
Definition: ismrx3.h:187
ismrx3_cfg_setup
void ismrx3_cfg_setup(ismrx3_cfg_t *cfg)
ISM RX 3 configuration object setup function.
ISMRX3_ERROR_BUF_LEN
@ ISMRX3_ERROR_BUF_LEN
Definition: ismrx3.h:223
ismrx3_cfg_t::miso
pin_name_t miso
Definition: ismrx3.h:197
ismrx3_cfg_t::dat
pin_name_t dat
Definition: ismrx3.h:203
ismrx3_generic_write
err_t ismrx3_generic_write(ismrx3_t *ctx, uint8_t reg, uint8_t data_in)
ISM RX 3 data writing function.
ismrx3_generic_read
err_t ismrx3_generic_read(ismrx3_t *ctx, uint8_t reg, uint8_t *data_out)
ISM RX 3 data reading function.
ismrx3_cfg_t::spi_speed
uint32_t spi_speed
Definition: ismrx3.h:209
ismrx3_t::int_pin
digital_in_t int_pin
Definition: ismrx3.h:178
ismrx3_get_clk
uint8_t ismrx3_get_clk(ismrx3_t *ctx)
Read clock output.
ismrx3_t::pdn
digital_out_t pdn
Definition: ismrx3.h:173
ismrx3_t::reference_freq
uint8_t reference_freq
Definition: ismrx3.h:185
ismrx3_cfg_t
ISM RX 3 Click configuration object.
Definition: ismrx3.h:195
ismrx3_t::freq_deviation
uint8_t freq_deviation
Definition: ismrx3.h:186
ismrx3_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: ismrx3.h:210
ismrx3_default_cfg
err_t ismrx3_default_cfg(ismrx3_t *ctx)
ISM RX 3 default configuration function.
ismrx3_cfg_t::pdn
pin_name_t pdn
Definition: ismrx3.h:204
ismrx3_return_value_t
ismrx3_return_value_t
ISM RX 3 Click return value data.
Definition: ismrx3.h:220
ismrx3_t::sw
digital_out_t sw
Definition: ismrx3.h:174
ismrx3_t::modulation
uint8_t modulation
Definition: ismrx3.h:184
ismrx3_t::dat
digital_in_t dat
Definition: ismrx3.h:177
ismrx3_t
ISM RX 3 Click context object.
Definition: ismrx3.h:171