leddriver 2.0.0.0
leddriver.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 LEDDRIVER_H
36#define LEDDRIVER_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 LEDDRIVER_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM )
60#define LEDDRIVER_RETVAL uint8_t
61
62#define LEDDRIVER_OK 0x00
63#define LEDDRIVER_INIT_ERROR 0xFF
64#define LEDDRIVER_FREQ_ERROR 0xFE
71#define LEDDRIVER_DEF_FREQ 10000 // End group macro
75// --------------------------------------------------------------- PUBLIC TYPES
84typedef struct
85{
86 pwm_t pwm;
87
88 uint32_t pwm_freq;
89
91
95typedef struct
96{
97 pin_name_t pwm;
98
99 uint32_t dev_pwm_freq;
100
102 // End types group
104// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
105
111#ifdef __cplusplus
112extern "C"{
113#endif
114
124
134
143
152err_t leddriver_set_duty_cycle ( leddriver_t *ctx, float duty_cycle );
153
162
171
172#ifdef __cplusplus
173}
174#endif
175#endif // _LEDDRIVER_H_
176 // End public_function group
179
180// ------------------------------------------------------------------------- END
#define LEDDRIVER_RETVAL
Definition: leddriver.h:60
err_t leddriver_set_duty_cycle(leddriver_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
void leddriver_cfg_setup(leddriver_cfg_t *cfg)
Config Object Initialization function.
uint16_t leddriver_get_pwm_max_duty(leddriver_t *ctx)
Get Max PWM Duty Cycle function.
LEDDRIVER_RETVAL leddriver_init(leddriver_t *ctx, leddriver_cfg_t *cfg)
Initialization function.
err_t leddriver_pwm_start(leddriver_t *ctx)
Start PWM module.
err_t leddriver_pwm_stop(leddriver_t *ctx)
Stop PWM module.
Click configuration structure definition.
Definition: leddriver.h:96
uint32_t dev_pwm_freq
Definition: leddriver.h:99
pin_name_t pwm
Definition: leddriver.h:97
Click ctx object definition.
Definition: leddriver.h:85
uint32_t pwm_freq
Definition: leddriver.h:88
pwm_t pwm
Definition: leddriver.h:86