ookrx  2.0.0.0
ookrx.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef OOKRX_H
36 #define OOKRX_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define OOKRX_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.rsi = MIKROBUS( mikrobus, MIKROBUS_AN ); \
53  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
54  cfg.sq = MIKROBUS( mikrobus, MIKROBUS_CS ); \
55  cfg.do_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
56 
62 #define OOKRX_RETVAL uint8_t
63 
64 #define OOKRX_OK 0x00
65 #define OOKRX_INIT_ERROR 0xFF
66  // End group macro
69 // --------------------------------------------------------------- PUBLIC TYPES
78 typedef struct
79 {
80  // Output pins
81 
82  digital_out_t en;
83  digital_out_t sq;
84 
85  // Input pins
86 
87  digital_in_t rsi;
88  digital_in_t do_pin;
89 
90 } ookrx_t;
91 
95 typedef struct
96 {
97  // Additional gpio pins
98 
99  pin_name_t rsi;
100  pin_name_t en;
101  pin_name_t sq;
102  pin_name_t do_pin;
103 
104 } ookrx_cfg_t;
105  // End types group
107 // ------------------------------------------------------------------ CONSTANTS // End constants group
116 // ------------------------------------------------------------------ VARIABLES // End variable group
124 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
125 
131 #ifdef __cplusplus
132 extern "C"{
133 #endif
134 
143 void ookrx_cfg_setup ( ookrx_cfg_t *cfg );
144 
153 
164 uint8_t ookrx_receive_data ( ookrx_t *ctx, uint16_t start_package,
165  uint8_t *receive_buffer, uint8_t bytes_num );
166 
174 uint8_t ookrx_read_do_pin ( ookrx_t *ctx );
175 
183 uint8_t ookrx_read_rsi_pin ( ookrx_t *ctx );
184 
185 #ifdef __cplusplus
186 }
187 #endif
188 #endif // _OOKRX_H_
189  // End public_function group
192 
193 // ------------------------------------------------------------------------- END
pin_name_t rsi
Definition: ookrx.h:99
uint8_t ookrx_read_rsi_pin(ookrx_t *ctx)
Read RSI pin function.
digital_out_t sq
Definition: ookrx.h:83
void ookrx_cfg_setup(ookrx_cfg_t *cfg)
Config Object Initialization function.
digital_in_t do_pin
Definition: ookrx.h:88
digital_in_t rsi
Definition: ookrx.h:87
pin_name_t sq
Definition: ookrx.h:101
pin_name_t do_pin
Definition: ookrx.h:102
pin_name_t en
Definition: ookrx.h:100
uint8_t ookrx_receive_data(ookrx_t *ctx, uint16_t start_package, uint8_t *receive_buffer, uint8_t bytes_num)
Receive data function.
Click configuration structure definition.
Definition: ookrx.h:95
#define OOKRX_RETVAL
Definition: ookrx.h:62
Click ctx object definition.
Definition: ookrx.h:78
uint8_t ookrx_read_do_pin(ookrx_t *ctx)
Read DO pin function.
OOKRX_RETVAL ookrx_init(ookrx_t *ctx, ookrx_cfg_t *cfg)
Initialization function.
digital_out_t en
Definition: ookrx.h:82