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
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 CURRENTLIMIT10_CMD_VREG 0x11
74#define CURRENTLIMIT10_CMD_NVREG 0x21
75#define CURRENTLIMIT10_CMD_VREGxNVREG 0x51
76#define CURRENTLIMIT10_CMD_NVREGxVREG 0x61
77
78 // currentlimit10_reg
79
94#define CURRENTLIMIT10_WIPER_POS_MIN 0
95#define CURRENTLIMIT10_WIPER_POS_MIDDLE 127
96#define CURRENTLIMIT10_WIPER_POS_MAX 255
97#define CURRENTLIMIT10_RES_200_KOHM 200.0f
98
103#define CURRENTLIMIT10_FAULT_FLAG 0
104
109#define CURRENTLIMIT10_COEFF_MULTI 0.37f
110#define CURRENTLIMIT10_TYP_V_ILIM_MV 289.0f
111#define CURRENTLIMIT10_RES_L_20_KOHM 20.0f
112#define CURRENTLIMIT10_LIMIT_MIN 0.5f
113#define CURRENTLIMIT10_LIMIT_MAX 5.5f
114
120#define CURRENTLIMIT10_DEVICE_ADDRESS 0x28
121
122 // currentlimit10_set
123
138#define CURRENTLIMIT10_MAP_MIKROBUS( cfg, mikrobus ) \
139 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
140 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
141 cfg.on = MIKROBUS( mikrobus, MIKROBUS_RST ); \
142 cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
143
144 // currentlimit10_map
145 // currentlimit10
146
151typedef struct
152{
153 // Output pins
154 digital_out_t on;
156 // Input pins
157 digital_in_t flt;
159 float offset;
161 // Modules
162 i2c_master_t i2c;
164 // I2C slave address
168
173typedef struct
174{
175 pin_name_t scl;
176 pin_name_t sda;
178 pin_name_t on;
179 pin_name_t flt;
181 uint32_t i2c_speed;
182 uint8_t i2c_address;
185
196
213
228
242
254
266
280err_t currentlimit10_write_data ( currentlimit10_t *ctx, uint8_t cmd, uint8_t data_in );
281
295err_t currentlimit10_set_wiper_pos ( currentlimit10_t *ctx, uint8_t wiper_pos );
296
310err_t currentlimit10_set_resistance ( currentlimit10_t *ctx, float res_kohm );
311
324err_t currentlimit10_set_limit ( currentlimit10_t *ctx, float current_limit );
325
341
342#ifdef __cplusplus
343}
344#endif
345#endif // CURRENTLIMIT10_H
346
347 // currentlimit10
348
349// ------------------------------------------------------------------------ END
currentlimit10_return_value_t
Current Limit 10 Click return value data.
Definition currentlimit10.h:191
@ CURRENTLIMIT10_ERROR
Definition currentlimit10.h:193
@ CURRENTLIMIT10_OK
Definition currentlimit10.h:192
err_t currentlimit10_write_data(currentlimit10_t *ctx, uint8_t cmd, uint8_t data_in)
Current Limit 10 I2C writing function.
void currentlimit10_cfg_setup(currentlimit10_cfg_t *cfg)
Current Limit 10 configuration object setup function.
err_t currentlimit10_default_cfg(currentlimit10_t *ctx)
Current Limit 10 default configuration function.
uint8_t currentlimit10_get_fault(currentlimit10_t *ctx)
Current Limit 10 get the fault flag function.
err_t currentlimit10_set_resistance(currentlimit10_t *ctx, float res_kohm)
Current Limit 10 sets the resistance function.
void currentlimit10_disable(currentlimit10_t *ctx)
Current Limit 10 disable the device function.
err_t currentlimit10_init(currentlimit10_t *ctx, currentlimit10_cfg_t *cfg)
Current Limit 10 initialization function.
err_t currentlimit10_set_limit(currentlimit10_t *ctx, float current_limit)
Current Limit 10 sets the current limit function.
void currentlimit10_enable(currentlimit10_t *ctx)
Current Limit 10 enable the device function.
err_t currentlimit10_set_wiper_pos(currentlimit10_t *ctx, uint8_t wiper_pos)
Current Limit 10 sets the wiper position function.
Current Limit 10 Click configuration object.
Definition currentlimit10.h:174
uint32_t i2c_speed
Definition currentlimit10.h:181
pin_name_t on
Definition currentlimit10.h:178
pin_name_t flt
Definition currentlimit10.h:179
pin_name_t scl
Definition currentlimit10.h:175
pin_name_t sda
Definition currentlimit10.h:176
uint8_t i2c_address
Definition currentlimit10.h:182
Current Limit 10 Click context object.
Definition currentlimit10.h:152
float offset
Definition currentlimit10.h:159
digital_in_t flt
Definition currentlimit10.h:157
digital_out_t on
Definition currentlimit10.h:154
i2c_master_t i2c
Definition currentlimit10.h:162
uint8_t slave_address
Definition currentlimit10.h:165