ooktx  2.1.0.0
ooktx.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 OOKTX_H
29 #define OOKTX_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 
73 #define OOKTX_TRAINING_BYTES { 0xAA, 0xAA, 0xAA, 0xAA }
74 #define OOKTX_MAN_MSB 0x8000
75 #define OOKTX_MAN_BIT_LEN_US 2000
76 #define OOKTX_MAX_DATA_LEN 255
77 #define OOKTX_CALIB_ENABLE 0x01
78 #define OOKTX_CALIB_DISABLE 0x00
79 #define OOKTX_CFG_ENABLE 0x01
80 #define OOKTX_CFG_DISABLE 0x00
81 #define OOKTX_CFG_DEFAULT 0xF6F0
82 #define OOKTX_CFG_F_433MHZ 0xF000
83 #define OOKTX_CFG_CX_18PF 0x0600
84 #define OOKTX_CFG_P_13DB 0x00F0
85 #define OOKTX_CFG_P_10DB 0x00C0
86 #define OOKTX_CFG_P_7DB 0x0090
87 #define OOKTX_CFG_P_3DB 0x0050
88 #define OOKTX_CFG_P_0DB 0x0020
89 #define OOKTX_CFG_CT_0PF 0x0000
90  // ooktx_cfg
92 
107 #define OOKTX_MAP_MIKROBUS( cfg, mikrobus ) \
108  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_CS ); \
109  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_PWM )
110  // ooktx_map // ooktx
113 
118 typedef struct
119 {
120  digital_out_t sda;
121  digital_out_t sck;
123 } ooktx_t;
124 
129 typedef struct
130 {
131  pin_name_t sda;
132  pin_name_t sck;
134 } ooktx_cfg_t;
135 
140 typedef enum
141 {
142  OOKTX_OK = 0,
143  OOKTX_ERROR = -1
144 
146 
163 
177 err_t ooktx_init ( ooktx_t *ctx, ooktx_cfg_t *cfg );
178 
188 
198 
208 
218 
230 void ooktx_start ( ooktx_t *ctx, uint8_t calib_en, uint8_t cfg_en, uint16_t cfg );
231 
243 void ooktx_stop ( ooktx_t *ctx );
244 
245 #ifdef __cplusplus
246 }
247 #endif
248 #endif // OOKTX_H
249  // ooktx
251 
252 // ------------------------------------------------------------------------ END
OOKTX_ERROR
@ OOKTX_ERROR
Definition: ooktx.h:143
ooktx_set_clock_pin
void ooktx_set_clock_pin(ooktx_t *ctx)
OOK TX set clock pin function.
ooktx_return_value_t
ooktx_return_value_t
OOK TX Click return value data.
Definition: ooktx.h:141
ooktx_cfg_t::sda
pin_name_t sda
Definition: ooktx.h:131
ooktx_cfg_t
OOK TX Click configuration object.
Definition: ooktx.h:130
ooktx_clear_data_pin
void ooktx_clear_data_pin(ooktx_t *ctx)
OOK TX clear data pin function.
OOKTX_OK
@ OOKTX_OK
Definition: ooktx.h:142
ooktx_stop
void ooktx_stop(ooktx_t *ctx)
OOK TX stop function.
ooktx_cfg_setup
void ooktx_cfg_setup(ooktx_cfg_t *cfg)
OOK TX configuration object setup function.
ooktx_clear_clock_pin
void ooktx_clear_clock_pin(ooktx_t *ctx)
OOK TX clear clock pin function.
ooktx_t::sck
digital_out_t sck
Definition: ooktx.h:121
ooktx_set_data_pin
void ooktx_set_data_pin(ooktx_t *ctx)
OOK TX set data pin function.
ooktx_start
void ooktx_start(ooktx_t *ctx, uint8_t calib_en, uint8_t cfg_en, uint16_t cfg)
OOK TX start function.
ooktx_t
OOK TX Click context object.
Definition: ooktx.h:119
ooktx_init
err_t ooktx_init(ooktx_t *ctx, ooktx_cfg_t *cfg)
OOK TX initialization function.
ooktx_cfg_t::sck
pin_name_t sck
Definition: ooktx.h:132
ooktx_t::sda
digital_out_t sda
Definition: ooktx.h:120