currentlimit10  2.1.0.0
currentlimit10.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 CURRENTLIMIT10_H
29 #define CURRENTLIMIT10_H
30 
31 #ifdef __cplusplus
32 extern "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 CURRENTLIMIT10_CMD_VREG 0x11
70 #define CURRENTLIMIT10_CMD_NVREG 0x21
71 #define CURRENTLIMIT10_CMD_VREGxNVREG 0x51
72 #define CURRENTLIMIT10_CMD_NVREGxVREG 0x61
73  // currentlimit10_reg
75 
90 #define CURRENTLIMIT10_WIPER_POS_MIN 0
91 #define CURRENTLIMIT10_WIPER_POS_MIDDLE 127
92 #define CURRENTLIMIT10_WIPER_POS_MAX 255
93 #define CURRENTLIMIT10_RES_200_KOHM 200.0f
94 
99 #define CURRENTLIMIT10_FAULT_FLAG 0
100 
105 #define CURRENTLIMIT10_COEFF_MULTI 0.37f
106 #define CURRENTLIMIT10_TYP_V_ILIM_MV 289.0f
107 #define CURRENTLIMIT10_RES_L_20_KOHM 20.0f
108 #define CURRENTLIMIT10_LIMIT_MIN 0.5f
109 #define CURRENTLIMIT10_LIMIT_MAX 5.5f
110 
116 #define CURRENTLIMIT10_DEVICE_ADDRESS 0x28
117  // currentlimit10_set
119 
134 #define CURRENTLIMIT10_MAP_MIKROBUS( cfg, mikrobus ) \
135  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
136  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
137  cfg.on = MIKROBUS( mikrobus, MIKROBUS_RST ); \
138  cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
139  // currentlimit10_map // currentlimit10
142 
147 typedef struct
148 {
149  // Output pins
150  digital_out_t on;
152  // Input pins
153  digital_in_t flt;
155  float offset;
157  // Modules
158  i2c_master_t i2c;
160  // I2C slave address
161  uint8_t slave_address;
164 
169 typedef struct
170 {
171  pin_name_t scl;
172  pin_name_t sda;
174  pin_name_t on;
175  pin_name_t flt;
177  uint32_t i2c_speed;
178  uint8_t i2c_address;
181 
186 typedef enum
187 {
190 
192 
209 
224 
238 
250 
262 
276 err_t currentlimit10_write_data ( currentlimit10_t *ctx, uint8_t cmd, uint8_t data_in );
277 
291 err_t currentlimit10_set_wiper_pos ( currentlimit10_t *ctx, uint8_t wiper_pos );
292 
306 err_t currentlimit10_set_resistance ( currentlimit10_t *ctx, float res_kohm );
307 
320 err_t currentlimit10_set_limit ( currentlimit10_t *ctx, float current_limit );
321 
337 
338 #ifdef __cplusplus
339 }
340 #endif
341 #endif // CURRENTLIMIT10_H
342  // currentlimit10
344 
345 // ------------------------------------------------------------------------ END
currentlimit10_set_limit
err_t currentlimit10_set_limit(currentlimit10_t *ctx, float current_limit)
Current Limit 10 sets the current limit function.
currentlimit10_t::i2c
i2c_master_t i2c
Definition: currentlimit10.h:158
currentlimit10_enable
void currentlimit10_enable(currentlimit10_t *ctx)
Current Limit 10 enable the device function.
currentlimit10_t::on
digital_out_t on
Definition: currentlimit10.h:150
currentlimit10_cfg_t::on
pin_name_t on
Definition: currentlimit10.h:174
currentlimit10_cfg_t::sda
pin_name_t sda
Definition: currentlimit10.h:172
currentlimit10_cfg_t::scl
pin_name_t scl
Definition: currentlimit10.h:171
currentlimit10_return_value_t
currentlimit10_return_value_t
Current Limit 10 Click return value data.
Definition: currentlimit10.h:187
currentlimit10_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: currentlimit10.h:177
currentlimit10_get_fault
uint8_t currentlimit10_get_fault(currentlimit10_t *ctx)
Current Limit 10 get the fault flag function.
currentlimit10_cfg_t
Current Limit 10 Click configuration object.
Definition: currentlimit10.h:170
currentlimit10_t
Current Limit 10 Click context object.
Definition: currentlimit10.h:148
currentlimit10_set_wiper_pos
err_t currentlimit10_set_wiper_pos(currentlimit10_t *ctx, uint8_t wiper_pos)
Current Limit 10 sets the wiper position function.
currentlimit10_t::slave_address
uint8_t slave_address
Definition: currentlimit10.h:161
currentlimit10_set_resistance
err_t currentlimit10_set_resistance(currentlimit10_t *ctx, float res_kohm)
Current Limit 10 sets the resistance function.
currentlimit10_cfg_t::i2c_address
uint8_t i2c_address
Definition: currentlimit10.h:178
currentlimit10_t::flt
digital_in_t flt
Definition: currentlimit10.h:153
currentlimit10_disable
void currentlimit10_disable(currentlimit10_t *ctx)
Current Limit 10 disable the device function.
CURRENTLIMIT10_ERROR
@ CURRENTLIMIT10_ERROR
Definition: currentlimit10.h:189
currentlimit10_t::offset
float offset
Definition: currentlimit10.h:155
currentlimit10_cfg_t::flt
pin_name_t flt
Definition: currentlimit10.h:175
currentlimit10_init
err_t currentlimit10_init(currentlimit10_t *ctx, currentlimit10_cfg_t *cfg)
Current Limit 10 initialization function.
CURRENTLIMIT10_OK
@ CURRENTLIMIT10_OK
Definition: currentlimit10.h:188
currentlimit10_default_cfg
err_t currentlimit10_default_cfg(currentlimit10_t *ctx)
Current Limit 10 default configuration function.
currentlimit10_cfg_setup
void currentlimit10_cfg_setup(currentlimit10_cfg_t *cfg)
Current Limit 10 configuration object setup function.
currentlimit10_write_data
err_t currentlimit10_write_data(currentlimit10_t *ctx, uint8_t cmd, uint8_t data_in)
Current Limit 10 I2C writing function.