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 
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 
66 #define ISMRX2_PIN_STATE_HIGH 1
67 #define ISMRX2_PIN_STATE_LOW 0
68 #define ISMRX2_DEFAULT_SYNC_BYTE 0xCE35
69 #define ISMRX2_FSK_DEFAULT_SYNC_BYTE 0xFF
70 
71  // ismrx2_set
73 
88 #define ISMRX2_MAP_MIKROBUS( cfg, mikrobus ) \
89  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
90  cfg.stb = MIKROBUS( mikrobus, MIKROBUS_CS ); \
91  cfg.mst = MIKROBUS( mikrobus, MIKROBUS_INT ); \
92  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX )
93  // ismrx2_map // ismrx2
96 
101 typedef struct
102 {
103  digital_out_t rst;
104  digital_out_t stb;
106  digital_in_t rx_pin;
107  digital_in_t mst;
109 } ismrx2_t;
110 
115 typedef struct
116 {
117  pin_name_t rst;
118  pin_name_t stb;
119  pin_name_t rx_pin;
120  pin_name_t mst;
122 } ismrx2_cfg_t;
123 
128 typedef enum
129 {
131  ISMRX2_ERROR = -1
132 
134 
151 
165 err_t ismrx2_init ( ismrx2_t *ctx, ismrx2_cfg_t *cfg );
166 
180 
190 void ismrx2_set_rst_pin_state ( ismrx2_t *ctx, uint8_t state );
191 
201 void ismrx2_set_stb_pin_state ( ismrx2_t *ctx, uint8_t state );
202 
212 
222 
234 err_t ismrx2_read_manchester_data ( ismrx2_t *ctx, uint8_t *data_out );
235 
247 err_t ismrx2_read_rf_data ( ismrx2_t *ctx, uint8_t *data_out );
248 
249 #ifdef __cplusplus
250 }
251 #endif
252 #endif // ISMRX2_H
253  // ismrx2
255 
256 // ------------------------------------------------------------------------ END
ismrx2_cfg_t::stb
pin_name_t stb
Definition: ismrx2.h:118
ISMRX2_ERROR
@ ISMRX2_ERROR
Definition: ismrx2.h:131
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:104
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:102
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:116
ismrx2_t::rst
digital_out_t rst
Definition: ismrx2.h:103
ismrx2_return_value_t
ismrx2_return_value_t
ISM RX 2 Click return value data.
Definition: ismrx2.h:129
ISMRX2_OK
@ ISMRX2_OK
Definition: ismrx2.h:130
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:117
ismrx2_cfg_t::rx_pin
pin_name_t rx_pin
Definition: ismrx2.h:119
ismrx2_t::mst
digital_in_t mst
Definition: ismrx2.h:107
ismrx2_cfg_t::mst
pin_name_t mst
Definition: ismrx2.h:120
ismrx2_t::rx_pin
digital_in_t rx_pin
Definition: ismrx2.h:106
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.