ismrx2  2.1.0.0
ismrx2.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 ISMRX2_H
29 #define ISMRX2_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 
62 #define ISMRX2_PIN_STATE_HIGH 1
63 #define ISMRX2_PIN_STATE_LOW 0
64 #define ISMRX2_DEFAULT_SYNC_BYTE 0xCE35
65 #define ISMRX2_FSK_DEFAULT_SYNC_BYTE 0xFF
66 
67  // ismrx2_set
69 
84 #define ISMRX2_MAP_MIKROBUS( cfg, mikrobus ) \
85  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
86  cfg.stb = MIKROBUS( mikrobus, MIKROBUS_CS ); \
87  cfg.mst = MIKROBUS( mikrobus, MIKROBUS_INT ); \
88  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX )
89  // ismrx2_map // ismrx2
92 
97 typedef struct
98 {
99  digital_out_t rst;
100  digital_out_t stb;
102  digital_in_t rx_pin;
103  digital_in_t mst;
105 } ismrx2_t;
106 
111 typedef struct
112 {
113  pin_name_t rst;
114  pin_name_t stb;
115  pin_name_t rx_pin;
116  pin_name_t mst;
118 } ismrx2_cfg_t;
119 
124 typedef enum
125 {
127  ISMRX2_ERROR = -1
128 
130 
147 
161 err_t ismrx2_init ( ismrx2_t *ctx, ismrx2_cfg_t *cfg );
162 
176 
186 void ismrx2_set_rst_pin_state ( ismrx2_t *ctx, uint8_t state );
187 
197 void ismrx2_set_stb_pin_state ( ismrx2_t *ctx, uint8_t state );
198 
208 
218 
230 err_t ismrx2_read_manchester_data ( ismrx2_t *ctx, uint8_t *data_out );
231 
243 err_t ismrx2_read_rf_data ( ismrx2_t *ctx, uint8_t *data_out );
244 
245 #ifdef __cplusplus
246 }
247 #endif
248 #endif // ISMRX2_H
249  // ismrx2
251 
252 // ------------------------------------------------------------------------ END
ismrx2_cfg_t::stb
pin_name_t stb
Definition: ismrx2.h:114
ISMRX2_ERROR
@ ISMRX2_ERROR
Definition: ismrx2.h:127
ismrx2_read_rf_data
err_t ismrx2_read_rf_data(ismrx2_t *ctx, uint8_t *data_out)
ISM RX 2 read data function.
ismrx2_t::stb
digital_out_t stb
Definition: ismrx2.h:100
ismrx2_get_data_pin_state
uint8_t ismrx2_get_data_pin_state(ismrx2_t *ctx)
ISM RX 2 get state of DATA pin function.
ismrx2_t
ISM RX 2 Click context object.
Definition: ismrx2.h:98
ismrx2_init
err_t ismrx2_init(ismrx2_t *ctx, ismrx2_cfg_t *cfg)
ISM RX 2 initialization function.
ismrx2_cfg_setup
void ismrx2_cfg_setup(ismrx2_cfg_t *cfg)
ISM RX 2 configuration object setup function.
ismrx2_read_manchester_data
err_t ismrx2_read_manchester_data(ismrx2_t *ctx, uint8_t *data_out)
ISM RX 2 read manchester encoded data function.
ismrx2_get_mst_pin_state
uint8_t ismrx2_get_mst_pin_state(ismrx2_t *ctx)
ISM RX 2 get state of MST pin function.
ismrx2_default_cfg
err_t ismrx2_default_cfg(ismrx2_t *ctx)
ISM RX 2 default configuration function.
ismrx2_cfg_t
ISM RX 2 Click configuration object.
Definition: ismrx2.h:112
ismrx2_t::rst
digital_out_t rst
Definition: ismrx2.h:99
ismrx2_return_value_t
ismrx2_return_value_t
ISM RX 2 Click return value data.
Definition: ismrx2.h:125
ISMRX2_OK
@ ISMRX2_OK
Definition: ismrx2.h:126
ismrx2_set_rst_pin_state
void ismrx2_set_rst_pin_state(ismrx2_t *ctx, uint8_t state)
ISM RX 2 set state of RST pin function.
ismrx2_cfg_t::rst
pin_name_t rst
Definition: ismrx2.h:113
ismrx2_cfg_t::rx_pin
pin_name_t rx_pin
Definition: ismrx2.h:115
ismrx2_t::mst
digital_in_t mst
Definition: ismrx2.h:103
ismrx2_cfg_t::mst
pin_name_t mst
Definition: ismrx2.h:116
ismrx2_t::rx_pin
digital_in_t rx_pin
Definition: ismrx2.h:102
ismrx2_set_stb_pin_state
void ismrx2_set_stb_pin_state(ismrx2_t *ctx, uint8_t state)
ISM RX 2 set state of STB pin function.