currentlimit5 2.0.0.0
currentlimit5.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 CURRENTLIMIT5_H
29#define CURRENTLIMIT5_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
73#define CURRENTLIMIT5_DIGIPOT_MAX_VALUE 5000
74#define CURRENTLIMIT5_DIGIPOT_OFFSET 80
75#define CURRENTLIMIT5_DIGIPOT_RESOLUTION 257
76#define CURRENTLIMIT5_ROUND_TO_NEAREST_INT 0.5
77
83#define CURRENTLIMIT5_SET_DEV_ADDR 0x2F
84
85 // currentlimit5_set
86
101#define CURRENTLIMIT5_MAP_MIKROBUS( cfg, mikrobus ) \
102 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
103 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
104 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
105 cfg.fault = MIKROBUS( mikrobus, MIKROBUS_INT )
106
107 // currentlimit5_map
108 // currentlimit5
109
114typedef struct
115{
116 // Output pins
117 digital_out_t en;
119 // Input pins
120 digital_in_t fault;
122 // Modules
123 i2c_master_t i2c;
125 // I2C slave address
129
134typedef struct
135{
136 pin_name_t scl;
137 pin_name_t sda;
139 pin_name_t en;
140 pin_name_t fault;
142 uint32_t i2c_speed;
143 uint8_t i2c_address;
146
157
177
194
210
225
240
251
261
271
272#ifdef __cplusplus
273}
274#endif
275#endif // CURRENTLIMIT5_H
276
277 // currentlimit5
278
279// ------------------------------------------------------------------------ END
currentlimit5_return_value_t
Current Limit 5 Click return value data.
Definition currentlimit5.h:152
@ CURRENTLIMIT5_ERROR
Definition currentlimit5.h:154
@ CURRENTLIMIT5_OK
Definition currentlimit5.h:153
currentlimit5_ilimit_t
Current Limit 5 Click Ilimit values.
Definition currentlimit5.h:163
@ CURRENTLIMIT5_ILIMIT_500mA
Definition currentlimit5.h:168
@ CURRENTLIMIT5_ILIMIT_1100mA
Definition currentlimit5.h:174
@ CURRENTLIMIT5_ILIMIT_300mA
Definition currentlimit5.h:166
@ CURRENTLIMIT5_ILIMIT_200mA
Definition currentlimit5.h:165
@ CURRENTLIMIT5_ILIMIT_700mA
Definition currentlimit5.h:170
@ CURRENTLIMIT5_ILIMIT_100mA
Definition currentlimit5.h:164
@ CURRENTLIMIT5_ILIMIT_1000mA
Definition currentlimit5.h:173
@ CURRENTLIMIT5_ILIMIT_900mA
Definition currentlimit5.h:172
@ CURRENTLIMIT5_ILIMIT_400mA
Definition currentlimit5.h:167
@ CURRENTLIMIT5_ILIMIT_600mA
Definition currentlimit5.h:169
@ CURRENTLIMIT5_ILIMIT_800mA
Definition currentlimit5.h:171
err_t currentlimit5_init(currentlimit5_t *ctx, currentlimit5_cfg_t *cfg)
Current Limit 5 initialization function.
void currentlimit5_enable_limit(currentlimit5_t *ctx)
Current Limit 5 enable limit function.
void currentlimit5_disable_limit(currentlimit5_t *ctx)
Current Limit 5 disable limit function.
void currentlimit5_cfg_setup(currentlimit5_cfg_t *cfg)
Current Limit 5 configuration object setup function.
uint8_t currentlimit5_get_fault_pin(currentlimit5_t *ctx)
Current Limit 5 get fault pin function.
err_t currentlimit5_default_cfg(currentlimit5_t *ctx)
Current Limit 5 default configuration function.
err_t currentlimit5_set_ilimit(currentlimit5_t *ctx, currentlimit5_ilimit_t ilimit)
Current Limit 5 set ilimit function.
Current Limit 5 Click configuration object.
Definition currentlimit5.h:135
uint32_t i2c_speed
Definition currentlimit5.h:142
pin_name_t scl
Definition currentlimit5.h:136
pin_name_t en
Definition currentlimit5.h:139
pin_name_t sda
Definition currentlimit5.h:137
pin_name_t fault
Definition currentlimit5.h:140
uint8_t i2c_address
Definition currentlimit5.h:143
Current Limit 5 Click context object.
Definition currentlimit5.h:115
i2c_master_t i2c
Definition currentlimit5.h:123
digital_out_t en
Definition currentlimit5.h:117
digital_in_t fault
Definition currentlimit5.h:120
uint8_t slave_address
Definition currentlimit5.h:126