irbeacon  2.0.0.0
irbeacon.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 IRBEACON_H
36 #define IRBEACON_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_pwm.h"
51 
52 // -------------------------------------------------------------- PUBLIC MACROS
62 #define IRBEACON_MAP_MIKROBUS( cfg, mikrobus ) \
63  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
64  cfg.mod = MIKROBUS( mikrobus, MIKROBUS_AN );
65 
71 #define IRBEACON_RETVAL uint8_t
72 
73 #define IRBEACON_OK 0x00
74 #define IRBEACON_INIT_ERROR 0xFF
75 
81 #define IRBEACON_DEF_FREQ 5000
82  // End group macro
85 // --------------------------------------------------------------- PUBLIC TYPES
94 typedef struct
95 {
96 
97  // Output pins
98 
99  digital_out_t mod;
100 
101  // Modules
102 
103  pwm_t pwm;
104 
105  // ctx variable
106 
107  uint16_t pwm_period;
108  uint32_t pwm_freq;
109 
110 } irbeacon_t;
111 
115 typedef struct
116 {
117  // Communication gpio pins
118 
119  pin_name_t pwm;
120 
121  // Additional gpio pins
122 
123  pin_name_t mod;
124 
125 
126  // static variable
127 
128  uint32_t dev_pwm_freq;
129 
131  // End types group
133 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
134 
140 #ifdef __cplusplus
141 extern "C"{
142 #endif
143 
153 
162 
172 void irbeacon_set_duty_cycle ( irbeacon_t *ctx, float duty_cycle );
173 
182 
191 
200 
209 
219 
220 #ifdef __cplusplus
221 }
222 #endif
223 #endif // _IRBEACON_H_
224  // End public_function group
227 
228 // ------------------------------------------------------------------------- END
irbeacon_t
Click ctx object definition.
Definition: irbeacon.h:95
irbeacon_init
IRBEACON_RETVAL irbeacon_init(irbeacon_t *ctx, irbeacon_cfg_t *cfg)
Initialization function.
irbeacon_set_duty_cycle
void irbeacon_set_duty_cycle(irbeacon_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
irbeacon_t::pwm_freq
uint32_t pwm_freq
Definition: irbeacon.h:108
irbeacon_cfg_t
Click configuration structure definition.
Definition: irbeacon.h:116
irbeacon_disable_mod
void irbeacon_disable_mod(irbeacon_t *ctx)
Disable MOD function.
irbeacon_reset_mod
void irbeacon_reset_mod(irbeacon_t *ctx)
Reset MOD function.
irbeacon_t::mod
digital_out_t mod
Definition: irbeacon.h:99
irbeacon_cfg_t::pwm
pin_name_t pwm
Definition: irbeacon.h:119
irbeacon_pwm_start
void irbeacon_pwm_start(irbeacon_t *ctx)
Start PWM module.
irbeacon_enable_mod
void irbeacon_enable_mod(irbeacon_t *ctx)
Enable MOD function.
irbeacon_cfg_setup
void irbeacon_cfg_setup(irbeacon_cfg_t *cfg)
Config Object Initialization function.
irbeacon_cfg_t::mod
pin_name_t mod
Definition: irbeacon.h:123
IRBEACON_RETVAL
#define IRBEACON_RETVAL
Definition: irbeacon.h:71
irbeacon_t::pwm_period
uint16_t pwm_period
Definition: irbeacon.h:107
irbeacon_t::pwm
pwm_t pwm
Definition: irbeacon.h:103
irbeacon_cfg_t::dev_pwm_freq
uint32_t dev_pwm_freq
Definition: irbeacon.h:128
irbeacon_pwm_stop
void irbeacon_pwm_stop(irbeacon_t *ctx)
Stop PWM module.