ledflash3 2.1.0.0
ledflash3.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef LEDFLASH3_H
29#define LEDFLASH3_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "mikrosdk_version.h"
36
37#ifdef __GNUC__
38#if mikroSDK_GET_VERSION < 20800ul
39#include "rcu_delays.h"
40#else
41#include "delays.h"
42#endif
43#endif
44
45#include "drv_digital_out.h"
46#include "drv_digital_in.h"
47#include "drv_i2c_master.h"
48
69#define LEDFLASH3_REG_ENABLE 0x01
70#define LEDFLASH3_REG_CONFIGURATION 0x02
71#define LEDFLASH3_REG_FLASH_CURRENT 0x03
72#define LEDFLASH3_REG_TOUCH_CURRENT 0x04
73#define LEDFLASH3_REG_FAULT_FLAG 0x05
74#define LEDFLASH3_REG_DEVICE_ID 0x06
75 // ledflash3_reg
77
92#define LEDFLASH3_LVP_ENABLE 0x10
93#define LEDFLASH3_STROBE_LEVEL 0x00
94#define LEDFLASH3_STROBE_EDGE 0x08
95#define LEDFLASH3_STROBE_PIN_ENABLE 0x04
96#define LEDFLASH3_MODE_FLASH 0x03
97#define LEDFLASH3_MODE_TORCH 0x02
98#define LEDFLASH3_MODE_IR 0x01
99#define LEDFLASH3_MODE_STANDBY 0x00
100
105#define LEDFLASH3_LVP_THRESHOLD_2V9 0x00
106#define LEDFLASH3_LVP_THRESHOLD_3V 0x02
107#define LEDFLASH3_LVP_THRESHOLD_3V1 0x04
108#define LEDFLASH3_LVP_THRESHOLD_3V2 0x06
109#define LEDFLASH3_LVP_THRESHOLD_3V3 0x08
110#define LEDFLASH3_LVP_THRESHOLD_3V4 0x0A
111#define LEDFLASH3_LVP_THRESHOLD_3V5 0x0C
112#define LEDFLASH3_LVP_THRESHOLD_3V6 0x0E
113#define LEDFLASH3_TIME_OUT_40MS 0x00
114#define LEDFLASH3_TIME_OUT_80MS 0x02
115#define LEDFLASH3_TIME_OUT_120MS 0x04
116#define LEDFLASH3_TIME_OUT_160MS 0x06
117#define LEDFLASH3_TIME_OUT_200MS 0x08
118#define LEDFLASH3_TIME_OUT_240MS 0x0A
119#define LEDFLASH3_TIME_OUT_280MS 0x0C
120#define LEDFLASH3_TIME_OUT_320MS 0x0E
121#define LEDFLASH3_TIME_OUT_360MS 0x10
122#define LEDFLASH3_TIME_OUT_400MS 0x12
123#define LEDFLASH3_TIME_OUT_600MS 0x14
124#define LEDFLASH3_TIME_OUT_800MS 0x16
125#define LEDFLASH3_TIME_OUT_1000MS 0x18
126#define LEDFLASH3_TIME_OUT_1200MS 0x1A
127#define LEDFLASH3_TIME_OUT_1400MS 0x1C
128#define LEDFLASH3_TIME_OUT_1600MS 0x1E
129#define LEDFLASH3_TORCH_RAMP_TIME_1MS 0x01
130
135#define LEDFLASH3_LVP_FAULT_MASK 0x40
136#define LEDFLASH3_LED_SHORT_FAULT_MASK 0x20
137#define LEDFLASH3_THERMAL_SHDN_MASK 0x04
138#define LEDFLASH3_THERMAL_SHDN_MASK 0x04
139#define LEDFLASH3_OVLO_FAULT_MASK 0x02
140#define LEDFLASH3_FLASH_TIMEOUT_MASK 0x01
141
146#define LEDFLASH3_SW_RESET_MASK 0x80
147
152#define LEDFLASH3_TORCH_CURRENT_MAX 376.0f
153#define LEDFLASH3_TORCH_CURRENT_MIN 2.94f
154#define LEDFLASH3_FLASH_CURRENT_MAX 1500.0f
155#define LEDFLASH3_FLASH_CURRENT_MIN 11.72f
156#define LEDFLASH3_ROUND_TO_NEAR_INT 0.5f
157
163#define LEDFLASH3_DEVICE_ADDRESS 0x64
164 // ledflash3_set
166
181#define LEDFLASH3_MAP_MIKROBUS( cfg, mikrobus ) \
182 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
183 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
184 cfg.stb = MIKROBUS( mikrobus, MIKROBUS_PWM )
185 // ledflash3_map // ledflash3
188
193typedef struct
194{
195 // Output pins
196 digital_out_t stb;
198 // Modules
199 i2c_master_t i2c;
201 // I2C slave address
205
210typedef struct
211{
212 pin_name_t scl;
213 pin_name_t sda;
215 pin_name_t stb;
217 uint32_t i2c_speed;
218 uint8_t i2c_address;
221
226typedef enum
227{
229 LEDFLASH3_ERROR = -1
230
232
249
264
278
293err_t ledflash3_generic_write ( ledflash3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
294
309err_t ledflash3_generic_read ( ledflash3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
310
324err_t ledflash3_write_reg ( ledflash3_t *ctx, uint8_t reg, uint8_t data_in );
325
339err_t ledflash3_read_reg ( ledflash3_t *ctx, uint8_t reg, uint8_t *data_out );
340
350
362err_t ledflash3_set_flash_current ( ledflash3_t *ctx, float flash_current );
363
375err_t ledflash3_set_torch_current ( ledflash3_t *ctx, float torch_current );
376
377#ifdef __cplusplus
378}
379#endif
380#endif // LEDFLASH3_H
381 // ledflash3
383
384// ------------------------------------------------------------------------ END
err_t ledflash3_generic_read(ledflash3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
LED Flash 3 I2C reading function.
err_t ledflash3_generic_write(ledflash3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
LED Flash 3 I2C writing function.
err_t ledflash3_write_reg(ledflash3_t *ctx, uint8_t reg, uint8_t data_in)
LED Flash 3 register writing function.
err_t ledflash3_default_cfg(ledflash3_t *ctx)
LED Flash 3 default configuration function.
err_t ledflash3_read_reg(ledflash3_t *ctx, uint8_t reg, uint8_t *data_out)
LED Flash 3 regiister reading function.
void ledflash3_strobe_pin(ledflash3_t *ctx)
LED Flash 3 strobe function.
err_t ledflash3_set_torch_current(ledflash3_t *ctx, float torch_current)
LED Flash 3 set torch current function.
void ledflash3_cfg_setup(ledflash3_cfg_t *cfg)
LED Flash 3 configuration object setup function.
err_t ledflash3_set_flash_current(ledflash3_t *ctx, float flash_current)
LED Flash 3 set flash current function.
err_t ledflash3_init(ledflash3_t *ctx, ledflash3_cfg_t *cfg)
LED Flash 3 initialization function.
ledflash3_return_value_t
LED Flash 3 Click return value data.
Definition: ledflash3.h:227
@ LEDFLASH3_ERROR
Definition: ledflash3.h:229
@ LEDFLASH3_OK
Definition: ledflash3.h:228
LED Flash 3 Click configuration object.
Definition: ledflash3.h:211
uint32_t i2c_speed
Definition: ledflash3.h:217
pin_name_t scl
Definition: ledflash3.h:212
pin_name_t sda
Definition: ledflash3.h:213
pin_name_t stb
Definition: ledflash3.h:215
uint8_t i2c_address
Definition: ledflash3.h:218
LED Flash 3 Click context object.
Definition: ledflash3.h:194
digital_out_t stb
Definition: ledflash3.h:196
i2c_master_t i2c
Definition: ledflash3.h:199
uint8_t slave_address
Definition: ledflash3.h:202