leddriver5  2.0.0.0
leddriver5.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 LEDDRIVER5_H
36 #define LEDDRIVER5_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 LEDDRIVER5_MAP_MIKROBUS( cfg, mikrobus ) \
63  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
64  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS );
65 
72 #define LEDDRIVER5_RETVAL uint8_t
73 
74 #define LEDDRIVER5_OK 0x00
75 #define LEDDRIVER5_INIT_ERROR 0xFF
76 
82 #define LEDDRIVER5_DEF_FREQ 5000
83  // End group macro
86 // --------------------------------------------------------------- PUBLIC TYPES
95 typedef struct
96 {
97 
98  // Output pins
99 
100  digital_out_t en;
101 
102  // Modules
103 
104  pwm_t pwm;
105 
106  // ctx variable
107 
108  uint32_t pwm_freq;
109 
110 } leddriver5_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 en;
124 
125  // static variable
126 
127  uint32_t dev_pwm_freq;
128 
130  // End types group
132 
133 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
134 
140 #ifdef __cplusplus
141 extern "C"{
142 #endif
143 
153 
162 
171 
181 void leddriver5_set_duty_cycle ( leddriver5_t *ctx, float duty_cycle );
182 
191 
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 #endif // _LEDDRIVER5_H_
205  // End public_function group
208 
209 // ------------------------------------------------------------------------- END
leddriver5_set_duty_cycle
void leddriver5_set_duty_cycle(leddriver5_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
leddriver5_t::pwm_freq
uint32_t pwm_freq
Definition: leddriver5.h:108
leddriver5_cfg_t::dev_pwm_freq
uint32_t dev_pwm_freq
Definition: leddriver5.h:127
leddriver5_t::pwm
pwm_t pwm
Definition: leddriver5.h:104
LEDDRIVER5_RETVAL
#define LEDDRIVER5_RETVAL
Definition: leddriver5.h:72
leddriver5_default_cfg
void leddriver5_default_cfg(leddriver5_t *ctx)
Click Default Configuration function.
leddriver5_cfg_t::pwm
pin_name_t pwm
Definition: leddriver5.h:119
leddriver5_t
Click ctx object definition.
Definition: leddriver5.h:96
leddriver5_cfg_t
Click configuration structure definition.
Definition: leddriver5.h:116
leddriver5_t::en
digital_out_t en
Definition: leddriver5.h:100
leddriver5_pwm_start
void leddriver5_pwm_start(leddriver5_t *ctx)
Start PWM module.
leddriver5_pwm_stop
void leddriver5_pwm_stop(leddriver5_t *ctx)
Stop PWM module.
leddriver5_cfg_t::en
pin_name_t en
Definition: leddriver5.h:123
leddriver5_cfg_setup
void leddriver5_cfg_setup(leddriver5_cfg_t *cfg)
Config Object Initialization function.
leddriver5_init
LEDDRIVER5_RETVAL leddriver5_init(leddriver5_t *ctx, leddriver5_cfg_t *cfg)
Initialization function.