leddriver2  2.0.0.0
leddriver2.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 LEDDRIVER2_H
36 #define LEDDRIVER2_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_pwm.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
52 #define LEDDRIVER2_MAP_MIKROBUS( cfg, mikrobus ) \
53  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM );
54 
60 #define LEDDRIVER2_RETVAL uint8_t
61 
62 #define LEDDRIVER2_OK 0x00
63 #define LEDDRIVER2_INIT_ERROR 0xFF
64 
70 #define LEDDRIVER2_DEF_FREQ 2000
71  // End group macro
74 // --------------------------------------------------------------- PUBLIC TYPES
83 typedef struct
84 {
85 
86  // Modules
87 
88  pwm_t pwm;
89 
90  // ctx variable
91 
92  uint32_t pwm_freq;
93 
94 } leddriver2_t;
95 
99 typedef struct
100 {
101  // Communication gpio pins
102 
103  pin_name_t pwm;
104 
105  // static variable
106 
107  uint32_t dev_pwm_freq;
108 
110  // End types group
112 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
113 
119 #ifdef __cplusplus
120 extern "C"{
121 #endif
122 
132 
141 
151 void leddriver2_set_duty_cycle ( leddriver2_t *ctx, float duty_cycle );
152 
161 
170 
171 #ifdef __cplusplus
172 }
173 #endif
174 #endif // _LEDDRIVER2_H_
175  // End public_function group
178 
179 // ------------------------------------------------------------------------- END
leddriver2_cfg_t::pwm
pin_name_t pwm
Definition: leddriver2.h:103
leddriver2_set_duty_cycle
void leddriver2_set_duty_cycle(leddriver2_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
leddriver2_cfg_t::dev_pwm_freq
uint32_t dev_pwm_freq
Definition: leddriver2.h:107
leddriver2_cfg_t
Click configuration structure definition.
Definition: leddriver2.h:100
leddriver2_cfg_setup
void leddriver2_cfg_setup(leddriver2_cfg_t *cfg)
Config Object Initialization function.
leddriver2_t
Click ctx object definition.
Definition: leddriver2.h:84
leddriver2_t::pwm_freq
uint32_t pwm_freq
Definition: leddriver2.h:92
LEDDRIVER2_RETVAL
#define LEDDRIVER2_RETVAL
Definition: leddriver2.h:60
leddriver2_pwm_stop
void leddriver2_pwm_stop(leddriver2_t *ctx)
Stop PWM module.
leddriver2_pwm_start
void leddriver2_pwm_start(leddriver2_t *ctx)
Start PWM module.
leddriver2_t::pwm
pwm_t pwm
Definition: leddriver2.h:88
leddriver2_init
LEDDRIVER2_RETVAL leddriver2_init(leddriver2_t *ctx, leddriver2_cfg_t *cfg)
Initialization function.