currentlimit9 2.1.0.0
currentlimit9.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 CURRENTLIMIT9_H
29#define CURRENTLIMIT9_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 CURRENTLIMIT9_CMD_VREG 0x11
74#define CURRENTLIMIT9_CMD_NVREG 0x21
75#define CURRENTLIMIT9_CMD_VREGxNVREG 0x51
76#define CURRENTLIMIT9_CMD_NVREGxVREG 0x61
77
78 // currentlimit9_reg
79
94#define CURRENTLIMIT9_WIPER_POS_MIN 0
95#define CURRENTLIMIT9_WIPER_POS_MIDDLE 127
96#define CURRENTLIMIT9_WIPER_POS_MAX 255
97#define CURRENTLIMIT9_RES_200_KOHM 200.0f
98
103#define CURRENTLIMIT9_FAULT_FLAG 0
104
109#define CURRENTLIMIT9_RESISTANCE 200.0f, 39.9f, 10.0f, 5.0f, 2.7f, 2.2f, 1.5f
110
116#define CURRENTLIMIT9_DEVICE_ADDRESS 0x28
117
118 // currentlimit9_set
119
134#define CURRENTLIMIT9_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
140 // currentlimit9_map
141 // currentlimit9
142
147typedef struct
148{
149 // Output pins
150 digital_out_t on;
152 // Input pins
153 digital_in_t flt;
155 // Modules
156 i2c_master_t i2c;
158 // I2C slave address
162
167typedef struct
168{
169 pin_name_t scl;
170 pin_name_t sda;
173 pin_name_t on;
174 pin_name_t flt;
176 uint32_t i2c_speed;
177 uint8_t i2c_address;
180
191
207
224
239
253
265
277
291err_t currentlimit9_write_data ( currentlimit9_t *ctx, uint8_t cmd, uint8_t data_in );
292
306err_t currentlimit9_set_wiper_pos ( currentlimit9_t *ctx, uint8_t wiper_pos );
307
321err_t currentlimit9_set_resistance ( currentlimit9_t *ctx, float res_kohm );
322
337
353
354#ifdef __cplusplus
355}
356#endif
357#endif // CURRENTLIMIT9_H
358
359 // currentlimit9
360
361// ------------------------------------------------------------------------ END
currentlimit9_return_value_t
Current Limit 9 Click return value data.
Definition currentlimit9.h:186
@ CURRENTLIMIT9_ERROR
Definition currentlimit9.h:188
@ CURRENTLIMIT9_OK
Definition currentlimit9.h:187
currentlimit9_limit_t
Current Limit 9 current limit values.
Definition currentlimit9.h:197
@ CURRENTLIMIT9_LIMIT_1_90_A
Definition currentlimit9.h:204
@ CURRENTLIMIT9_LIMIT_1_84_A
Definition currentlimit9.h:203
@ CURRENTLIMIT9_LIMIT_1_55_A
Definition currentlimit9.h:201
@ CURRENTLIMIT9_LIMIT_0_46_A
Definition currentlimit9.h:199
@ CURRENTLIMIT9_LIMIT_1_17_A
Definition currentlimit9.h:200
@ CURRENTLIMIT9_LIMIT_0_11_A
Definition currentlimit9.h:198
@ CURRENTLIMIT9_LIMIT_1_67_A
Definition currentlimit9.h:202
err_t currentlimit9_default_cfg(currentlimit9_t *ctx)
Current Limit 9 default configuration function.
err_t currentlimit9_set_resistance(currentlimit9_t *ctx, float res_kohm)
Current Limit 9 sets the resistance function.
err_t currentlimit9_init(currentlimit9_t *ctx, currentlimit9_cfg_t *cfg)
Current Limit 9 initialization function.
void currentlimit9_enable(currentlimit9_t *ctx)
Current Limit 9 enable the device function.
err_t currentlimit9_set_limit(currentlimit9_t *ctx, currentlimit9_limit_t current_limit)
Current Limit 9 sets the current limit function.
void currentlimit9_cfg_setup(currentlimit9_cfg_t *cfg)
Current Limit 9 configuration object setup function.
uint8_t currentlimit9_get_fault(currentlimit9_t *ctx)
Current Limit 9 get the fault flag function.
void currentlimit9_disable(currentlimit9_t *ctx)
Current Limit 9 disable the device function.
err_t currentlimit9_set_wiper_pos(currentlimit9_t *ctx, uint8_t wiper_pos)
Current Limit 9 sets the wiper position function.
err_t currentlimit9_write_data(currentlimit9_t *ctx, uint8_t cmd, uint8_t data_in)
Current Limit 9 I2C writing function.
Current Limit 9 Click configuration object.
Definition currentlimit9.h:168
uint32_t i2c_speed
Definition currentlimit9.h:176
pin_name_t on
Definition currentlimit9.h:173
pin_name_t flt
Definition currentlimit9.h:174
pin_name_t scl
Definition currentlimit9.h:169
pin_name_t sda
Definition currentlimit9.h:170
uint8_t i2c_address
Definition currentlimit9.h:177
Current Limit 9 Click context object.
Definition currentlimit9.h:148
digital_in_t flt
Definition currentlimit9.h:153
digital_out_t on
Definition currentlimit9.h:150
i2c_master_t i2c
Definition currentlimit9.h:156
uint8_t slave_address
Definition currentlimit9.h:159