ismrx  2.0.0.0
ismrx.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 ISMRX_H
29 #define ISMRX_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 ISMRX_REG_POWER_CFG 0x00
60 #define ISMRX_REG_CFG 0x01
61 #define ISMRX_REG_CTRL 0x02
62 #define ISMRX_REG_OSC_FREQ 0x03
63 #define ISMRX_REG_OFF_TIMER_MSB 0x04
64 #define ISMRX_REG_OFF_TIMER_LSB 0x05
65 #define ISMRX_REG_CPU_RECOVERY_TIME 0x06
66 #define ISMRX_REG_RF_SETTLE_TIMER_MSB 0x07
67 #define ISMRX_REG_RF_SETTLE_TIMER_LSB 0x08
68 #define ISMRX_REG_STATUS 0x09
69 #define ISMRX_REG_AGC_DWELL_TIMER 0x0A
70  // ismrx_reg
72 
87 #define ISMRX_MODULATION_NULL 0
88 #define ISMRX_MODULATION_ASK 1
89 #define ISMRX_MODULATION_FSK 2
90 
91 #define ISMRX_RECEIVE_MODE_NULL 0
92 #define ISMRX_RECEIVE_MODE_RX 3
93 #define ISMRX_RECEIVE_MODE_DRX 4
94  // ismrx_set
96 
111 #define ISMRX_MAP_MIKROBUS( cfg, mikrobus ) \
112  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
113  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
114  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
115  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
116  // ismrx_map // ismrx
119 
124 typedef struct
125 {
126  // Output pins
127  digital_out_t mosi;
128  digital_out_t cs;
130  // Input pins
131  digital_in_t miso;
133  // Modules
134  spi_master_t spi;
135  pin_name_t chip_select;
137  uint8_t modulation;
138  uint8_t receive_mode;
139 
140 } ismrx_t;
141 
146 typedef struct
147 {
148  // Communication gpio pins
149  pin_name_t miso;
150  pin_name_t mosi;
151  pin_name_t sck;
152  pin_name_t cs;
154  // static variable
155 
156  uint32_t spi_speed;
157  spi_master_mode_t spi_mode;
158  spi_master_chip_select_polarity_t cs_polarity;
160 } ismrx_cfg_t;
161 
166 typedef enum
167 {
168  ISMRX_OK = 0,
172 
174 
190 void ismrx_cfg_setup ( ismrx_cfg_t *cfg );
191 
205 err_t ismrx_init ( ismrx_t *ctx, ismrx_cfg_t *cfg );
206 
207 
221 err_t ismrx_task_init ( ismrx_t *ctx, ismrx_cfg_t *cfg );
222 
236 err_t ismrx_default_cfg ( ismrx_t *ctx );
237 
252 err_t ismrx_generic_write ( ismrx_t *ctx, uint8_t reg, uint8_t data_in );
253 
268 err_t ismrx_generic_read ( ismrx_t *ctx, uint8_t reg, uint8_t *data_out );
269 
281 err_t ismrx_master_reset ( ismrx_t *ctx );
282 
290 void ismrx_start_drx ( ismrx_t *ctx );
291 
299 void ismrx_stop_drx ( ismrx_t *ctx );
300 
308 uint8_t ismrx_get_data ( ismrx_t *ctx );
309 
310 #ifdef __cplusplus
311 }
312 #endif
313 #endif // ISMRX_H
314  // ismrx
316 
317 // ------------------------------------------------------------------------ END
ISMRX_OK
Definition: ismrx.h:167
ISMRX_ERROR
Definition: ismrx.h:168
ismrx_t
ISM RX Click context object.
Definition: ismrx.h:123
ismrx_task_init
err_t ismrx_task_init(ismrx_t *ctx, ismrx_cfg_t *cfg)
ISM RX initialization function.
ismrx_get_data
uint8_t ismrx_get_data(ismrx_t *ctx)
ISM RX get miso pin state.
ismrx_cfg_t
ISM RX Click configuration object.
Definition: ismrx.h:145
ISMRX_CONTEXT_MODULATION_ERROR
Definition: ismrx.h:169
ismrx_default_cfg
err_t ismrx_default_cfg(ismrx_t *ctx)
ISM RX default configuration function.
ismrx_cfg_setup
void ismrx_cfg_setup(ismrx_cfg_t *cfg)
ISM RX configuration object setup function.
ismrx_generic_read
err_t ismrx_generic_read(ismrx_t *ctx, uint8_t reg, uint8_t *data_out)
ISM RX data reading function.
ismtx_return_value_t
ismtx_return_value_t
ISM RX Click return value data.
Definition: ismrx.h:165
ismrx_start_drx
void ismrx_start_drx(ismrx_t *ctx)
ISM RX start receiving signal.
ismrx_stop_drx
void ismrx_stop_drx(ismrx_t *ctx)
ISM RX stop receiving signal.
ismrx_master_reset
err_t ismrx_master_reset(ismrx_t *ctx)
ISM RX software reset.
ISMRX_CONTEXT_RECEIVE_MODE_ERROR
Definition: ismrx.h:170
ismrx_init
err_t ismrx_init(ismrx_t *ctx, ismrx_cfg_t *cfg)
ISM RX initialization function.
ismrx_generic_write
err_t ismrx_generic_write(ismrx_t *ctx, uint8_t reg, uint8_t data_in)
ISM RX data writing function.