lighttemp 2.0.0.0
lighttemp.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 LIGHTTEMP_H
36#define LIGHTTEMP_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_i2c_master.h"
41#include "drv_pwm.h"
42
43// -------------------------------------------------------------- PUBLIC MACROS
53#define LIGHTTEMP_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56 cfg.pwm1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
57 cfg.pwm2 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
58 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
65#define LIGHTTEMP_RETVAL uint8_t
66
67#define LIGHTTEMP_OK 0x00
68#define LIGHTTEMP_INIT_ERROR 0xFF
75#define LIGHTTEMP_DEF_FREQ 20000 // End group macro
79// --------------------------------------------------------------- PUBLIC TYPES
88typedef struct
89{
90 // Input pins
91
92 digital_in_t int_pin;
93
94 // Modules
95
96 i2c_master_t i2c;
97 pwm_t pwm1;
98 pwm_t pwm2;
99
100 // ctx variable
101
103 uint32_t pwm_freq;
104
106
110typedef struct
111{
112 // Communication gpio pins
113
114 pin_name_t scl;
115 pin_name_t sda;
116 pin_name_t pwm1;
117 pin_name_t pwm2;
118
119 // Additional gpio pins
120
121 pin_name_t int_pin;
122
123 // static variable
124
125 uint32_t i2c_speed;
126 uint8_t i2c_address;
127 uint32_t dev_pwm_freq;
128
130 // End types group
132// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
133
139#ifdef __cplusplus
140extern "C"{
141#endif
142
152
162
173void lighttemp_generic_write ( lighttemp_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
174
185void lighttemp_generic_read ( lighttemp_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
186
195
205
214void lighttemp_led1_set_duty_cycle ( lighttemp_t *ctx, float duty_cycle );
215
224
233
242void lighttemp_led2_set_duty_cycle ( lighttemp_t *ctx, float duty_cycle );
243
252
261#ifdef __cplusplus
262}
263#endif
264#endif // _LIGHTTEMP_H_
265 // End public_function group
268
269// ------------------------------------------------------------------------- END
#define LIGHTTEMP_RETVAL
Definition: lighttemp.h:65
void lighttemp_led1_pwm_stop(lighttemp_t *ctx)
Stop PWM module for LED1.
uint8_t lighttemp_get_interrupt_state(lighttemp_t *ctx)
Get INT pin state.
void lighttemp_led1_pwm_start(lighttemp_t *ctx)
Start PWM module for LED1.
LIGHTTEMP_RETVAL lighttemp_init(lighttemp_t *ctx, lighttemp_cfg_t *cfg)
Initialization function.
void lighttemp_led2_pwm_stop(lighttemp_t *ctx)
Stop PWM module for LED2.
void lighttemp_led2_pwm_start(lighttemp_t *ctx)
Start PWM module for LED2.
void lighttemp_led1_set_duty_cycle(lighttemp_t *ctx, float duty_cycle)
Generic sets PWM duty cycle for LED1.
void lighttemp_cfg_setup(lighttemp_cfg_t *cfg)
Config Object Initialization function.
void lighttemp_generic_write(lighttemp_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void lighttemp_generic_read(lighttemp_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint16_t lighttemp_get_pg_voltage(lighttemp_t *ctx)
Get voltage.
void lighttemp_led2_set_duty_cycle(lighttemp_t *ctx, float duty_cycle)
Generic sets PWM duty cycle for LED2.
Click configuration structure definition.
Definition: lighttemp.h:111
uint32_t i2c_speed
Definition: lighttemp.h:125
uint32_t dev_pwm_freq
Definition: lighttemp.h:127
pin_name_t scl
Definition: lighttemp.h:114
pin_name_t pwm1
Definition: lighttemp.h:116
pin_name_t int_pin
Definition: lighttemp.h:121
pin_name_t sda
Definition: lighttemp.h:115
pin_name_t pwm2
Definition: lighttemp.h:117
uint8_t i2c_address
Definition: lighttemp.h:126
Click ctx object definition.
Definition: lighttemp.h:89
pwm_t pwm1
Definition: lighttemp.h:97
pwm_t pwm2
Definition: lighttemp.h:98
uint32_t pwm_freq
Definition: lighttemp.h:103
digital_in_t int_pin
Definition: lighttemp.h:92
i2c_master_t i2c
Definition: lighttemp.h:96
uint8_t slave_address
Definition: lighttemp.h:102