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
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_pwm.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define IRBEACON_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
68 cfg.mod = MIKROBUS( mikrobus, MIKROBUS_AN );
75#define IRBEACON_RETVAL uint8_t
76
77#define IRBEACON_OK 0x00
78#define IRBEACON_INIT_ERROR 0xFF
85#define IRBEACON_DEF_FREQ 5000
88 // End group macro
89// --------------------------------------------------------------- PUBLIC TYPES
98typedef struct
99{
100
101 // Output pins
102
103 digital_out_t mod;
104
105 // Modules
106
107 pwm_t pwm;
108
109 // ctx variable
110
111 uint16_t pwm_period;
112 uint32_t pwm_freq;
113
114} irbeacon_t;
115
119typedef struct
120{
121 // Communication gpio pins
122
123 pin_name_t pwm;
124
125 // Additional gpio pins
126
127 pin_name_t mod;
128
129
130 // static variable
131
132 uint32_t dev_pwm_freq;
133
135
136 // End types group
137// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
138
144#ifdef __cplusplus
145extern "C"{
146#endif
147
157
166
176void irbeacon_set_duty_cycle ( irbeacon_t *ctx, float duty_cycle );
177
186
195
204
213
223
224#ifdef __cplusplus
225}
226#endif
227#endif // _IRBEACON_H_
228
229 // End public_function group
231
232// ------------------------------------------------------------------------- END
#define IRBEACON_RETVAL
Definition irbeacon.h:75
void irbeacon_pwm_stop(irbeacon_t *ctx)
Stop PWM module.
void irbeacon_cfg_setup(irbeacon_cfg_t *cfg)
Config Object Initialization function.
IRBEACON_RETVAL irbeacon_init(irbeacon_t *ctx, irbeacon_cfg_t *cfg)
Initialization function.
void irbeacon_reset_mod(irbeacon_t *ctx)
Reset MOD function.
void irbeacon_enable_mod(irbeacon_t *ctx)
Enable MOD function.
void irbeacon_set_duty_cycle(irbeacon_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
void irbeacon_disable_mod(irbeacon_t *ctx)
Disable MOD function.
void irbeacon_pwm_start(irbeacon_t *ctx)
Start PWM module.
Click configuration structure definition.
Definition irbeacon.h:120
pin_name_t mod
Definition irbeacon.h:127
uint32_t dev_pwm_freq
Definition irbeacon.h:132
pin_name_t pwm
Definition irbeacon.h:123
Click ctx object definition.
Definition irbeacon.h:99
digital_out_t mod
Definition irbeacon.h:103
uint32_t pwm_freq
Definition irbeacon.h:112
pwm_t pwm
Definition irbeacon.h:107
uint16_t pwm_period
Definition irbeacon.h:111