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
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_i2c_master.h"
38
59#define CURRENTLIMIT5_DIGIPOT_MAX_VALUE 5000
60#define CURRENTLIMIT5_DIGIPOT_OFFSET 80
61#define CURRENTLIMIT5_DIGIPOT_RESOLUTION 257
62#define CURRENTLIMIT5_ROUND_TO_NEAREST_INT 0.5
63
69#define CURRENTLIMIT5_SET_DEV_ADDR 0x2F
70 // currentlimit5_set
72
87#define CURRENTLIMIT5_MAP_MIKROBUS( cfg, mikrobus ) \
88 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
89 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
90 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
91 cfg.fault = MIKROBUS( mikrobus, MIKROBUS_INT )
92 // currentlimit5_map // currentlimit5
95
100typedef struct
101{
102 // Output pins
103 digital_out_t en;
105 // Input pins
106 digital_in_t fault;
108 // Modules
109 i2c_master_t i2c;
111 // I2C slave address
115
120typedef struct
121{
122 pin_name_t scl;
123 pin_name_t sda;
125 pin_name_t en;
126 pin_name_t fault;
128 uint32_t i2c_speed;
129 uint8_t i2c_address;
132
137typedef enum
138{
141
143
148typedef enum
149{
161
163
180
196
211
226
237
247
257
258#ifdef __cplusplus
259}
260#endif
261#endif // CURRENTLIMIT5_H
262 // currentlimit5
264
265// ------------------------------------------------------------------------ END
currentlimit5_return_value_t
Current Limit 5 Click return value data.
Definition: currentlimit5.h:138
@ CURRENTLIMIT5_ERROR
Definition: currentlimit5.h:140
@ CURRENTLIMIT5_OK
Definition: currentlimit5.h:139
currentlimit5_ilimit_t
Current Limit 5 Click Ilimit values.
Definition: currentlimit5.h:149
@ CURRENTLIMIT5_ILIMIT_500mA
Definition: currentlimit5.h:154
@ CURRENTLIMIT5_ILIMIT_1100mA
Definition: currentlimit5.h:160
@ CURRENTLIMIT5_ILIMIT_300mA
Definition: currentlimit5.h:152
@ CURRENTLIMIT5_ILIMIT_200mA
Definition: currentlimit5.h:151
@ CURRENTLIMIT5_ILIMIT_700mA
Definition: currentlimit5.h:156
@ CURRENTLIMIT5_ILIMIT_100mA
Definition: currentlimit5.h:150
@ CURRENTLIMIT5_ILIMIT_1000mA
Definition: currentlimit5.h:159
@ CURRENTLIMIT5_ILIMIT_900mA
Definition: currentlimit5.h:158
@ CURRENTLIMIT5_ILIMIT_400mA
Definition: currentlimit5.h:153
@ CURRENTLIMIT5_ILIMIT_600mA
Definition: currentlimit5.h:155
@ CURRENTLIMIT5_ILIMIT_800mA
Definition: currentlimit5.h:157
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:121
uint32_t i2c_speed
Definition: currentlimit5.h:128
pin_name_t scl
Definition: currentlimit5.h:122
pin_name_t en
Definition: currentlimit5.h:125
pin_name_t sda
Definition: currentlimit5.h:123
pin_name_t fault
Definition: currentlimit5.h:126
uint8_t i2c_address
Definition: currentlimit5.h:129
Current Limit 5 Click context object.
Definition: currentlimit5.h:101
i2c_master_t i2c
Definition: currentlimit5.h:109
digital_out_t en
Definition: currentlimit5.h:103
digital_in_t fault
Definition: currentlimit5.h:106
uint8_t slave_address
Definition: currentlimit5.h:112