efuse5  2.1.0.0
efuse5.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 EFUSE5_H
29 #define EFUSE5_H
30 
31 #ifdef __cplusplus
32 extern "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 EFUSE5_WRITE_TO_RDAC 0x00
60 #define EFUSE5_ONE_TIME_PROG 0x80
61 
62  // efuse5_inst
64 
79 #define EFUSE5_OTP_V_READY 0x00
80 #define EFUSE5_OTP_V_TEST_FUSE_OK 0x40
81 #define EFUSE5_OTP_V_ERROR 0x80
82 #define EFUSE5_OTP_V_PROG_SUCCESS 0xC0
83 
89 #define EFUSE5_DEVICE_ADDRESS 0x2C
90  // efuse5_set
92 
107 #define EFUSE5_MAP_MIKROBUS( cfg, mikrobus ) \
108  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
109  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
110  cfg.mon = MIKROBUS( mikrobus, MIKROBUS_AN ); \
111  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
112  cfg.pgd = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
113  cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
114  // efuse5_map // efuse5
117 
122 typedef struct
123 {
124  // Output pins
125  digital_out_t en;
127  // Input pins
128  digital_in_t mon;
129  digital_in_t pgd;
130  digital_in_t flt;
132  // Modules
133  i2c_master_t i2c;
135  // I2C slave address
136  uint8_t slave_address;
138 } efuse5_t;
139 
144 typedef struct
145 {
146  pin_name_t scl;
147  pin_name_t sda;
149  pin_name_t mon;
150  pin_name_t en;
151  pin_name_t pgd;
152  pin_name_t flt;
154  uint32_t i2c_speed;
155  uint8_t i2c_address;
157 } efuse5_cfg_t;
158 
163 typedef enum
164 {
175 
177 
182 typedef enum
183 {
185  EFUSE5_ERROR = -1
186 
188 
205 
219 err_t efuse5_init ( efuse5_t *ctx, efuse5_cfg_t *cfg );
220 
234 
248 err_t efuse5_write_byte ( efuse5_t *ctx, uint8_t inst, uint8_t data_in );
249 
262 err_t efuse5_generic_read ( efuse5_t *ctx, uint8_t *data_out );
263 
277 err_t efuse5_write_rdac ( efuse5_t *ctx, uint8_t rdac_data );
278 
292 err_t efuse5_read_rdac ( efuse5_t *ctx, uint8_t *rdac_data );
293 
307 err_t efuse5_set_digi_pot ( efuse5_t *ctx, uint8_t wiper_pos );
308 
323 err_t efuse5_set_resistance ( efuse5_t *ctx, uint16_t res_ohm );
324 
339 
352 
364 void efuse5_shutdown ( efuse5_t *ctx );
365 
376 uint8_t efuse5_get_imon ( efuse5_t *ctx );
377 
389 uint8_t efuse5_get_pgood ( efuse5_t *ctx );
390 
402 uint8_t efuse5_get_fault ( efuse5_t *ctx );
403 
404 #ifdef __cplusplus
405 }
406 #endif
407 #endif // EFUSE5_H
408  // efuse5
410 
411 // ------------------------------------------------------------------------ END
efuse5_cfg_t::mon
pin_name_t mon
Definition: efuse5.h:149
efuse5_t::flt
digital_in_t flt
Definition: efuse5.h:130
efuse5_cfg_t
eFuse 5 Click configuration object.
Definition: efuse5.h:145
efuse5_default_cfg
err_t efuse5_default_cfg(efuse5_t *ctx)
eFuse 5 default configuration function.
efuse5_set_resistance
err_t efuse5_set_resistance(efuse5_t *ctx, uint16_t res_ohm)
eFuse 5 set the resistance function.
efuse5_cfg_t::pgd
pin_name_t pgd
Definition: efuse5.h:151
efuse5_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: efuse5.h:154
efuse5_write_rdac
err_t efuse5_write_rdac(efuse5_t *ctx, uint8_t rdac_data)
eFuse 5 write RDAC function.
efuse5_enable_device
void efuse5_enable_device(efuse5_t *ctx)
eFuse 5 enable the device function.
efuse5_t::pgd
digital_in_t pgd
Definition: efuse5.h:129
EFUSE5_ERROR
@ EFUSE5_ERROR
Definition: efuse5.h:185
efuse5_set_digi_pot
err_t efuse5_set_digi_pot(efuse5_t *ctx, uint8_t wiper_pos)
eFuse 5 set the digital potentiometer function.
efuse5_cfg_t::en
pin_name_t en
Definition: efuse5.h:150
efuse5_t::en
digital_out_t en
Definition: efuse5.h:125
efuse5_cfg_t::flt
pin_name_t flt
Definition: efuse5.h:152
efuse5_get_fault
uint8_t efuse5_get_fault(efuse5_t *ctx)
eFuse 5 gets fault condition state function.
EFUSE5_CURRENT_LIMIT_720_mA
@ EFUSE5_CURRENT_LIMIT_720_mA
Definition: efuse5.h:166
EFUSE5_CURRENT_LIMIT_4500_mA
@ EFUSE5_CURRENT_LIMIT_4500_mA
Definition: efuse5.h:174
efuse5_read_rdac
err_t efuse5_read_rdac(efuse5_t *ctx, uint8_t *rdac_data)
eFuse 5 read RDAC function.
efuse5_get_pgood
uint8_t efuse5_get_pgood(efuse5_t *ctx)
eFuse 5 gets power good state function.
efuse5_current_limit_t
efuse5_current_limit_t
eFuse 5 Click current limit value data.
Definition: efuse5.h:164
efuse5_set_current_limit
err_t efuse5_set_current_limit(efuse5_t *ctx, efuse5_current_limit_t current_limit)
eFuse 5 set the current limit function.
efuse5_return_value_t
efuse5_return_value_t
eFuse 5 Click return value data.
Definition: efuse5.h:183
efuse5_shutdown
void efuse5_shutdown(efuse5_t *ctx)
eFuse 5 disable the device function.
EFUSE5_CURRENT_LIMIT_1030_mA
@ EFUSE5_CURRENT_LIMIT_1030_mA
Definition: efuse5.h:169
EFUSE5_CURRENT_LIMIT_600_mA
@ EFUSE5_CURRENT_LIMIT_600_mA
Definition: efuse5.h:165
efuse5_t::slave_address
uint8_t slave_address
Definition: efuse5.h:136
efuse5_cfg_t::i2c_address
uint8_t i2c_address
Definition: efuse5.h:155
efuse5_generic_read
err_t efuse5_generic_read(efuse5_t *ctx, uint8_t *data_out)
eFuse 5 I2C reading function.
efuse5_t
eFuse 5 Click context object.
Definition: efuse5.h:123
efuse5_write_byte
err_t efuse5_write_byte(efuse5_t *ctx, uint8_t inst, uint8_t data_in)
eFuse 5 I2C writing function.
efuse5_get_imon
uint8_t efuse5_get_imon(efuse5_t *ctx)
eFuse 5 get imon function.
EFUSE5_CURRENT_LIMIT_900_mA
@ EFUSE5_CURRENT_LIMIT_900_mA
Definition: efuse5.h:168
EFUSE5_CURRENT_LIMIT_2000_mA
@ EFUSE5_CURRENT_LIMIT_2000_mA
Definition: efuse5.h:173
efuse5_t::mon
digital_in_t mon
Definition: efuse5.h:128
efuse5_cfg_t::scl
pin_name_t scl
Definition: efuse5.h:146
EFUSE5_CURRENT_LIMIT_1445_mA
@ EFUSE5_CURRENT_LIMIT_1445_mA
Definition: efuse5.h:171
efuse5_cfg_t::sda
pin_name_t sda
Definition: efuse5.h:147
efuse5_init
err_t efuse5_init(efuse5_t *ctx, efuse5_cfg_t *cfg)
eFuse 5 initialization function.
efuse5_t::i2c
i2c_master_t i2c
Definition: efuse5.h:133
EFUSE5_CURRENT_LIMIT_1200_mA
@ EFUSE5_CURRENT_LIMIT_1200_mA
Definition: efuse5.h:170
EFUSE5_CURRENT_LIMIT_865_mA
@ EFUSE5_CURRENT_LIMIT_865_mA
Definition: efuse5.h:167
EFUSE5_OK
@ EFUSE5_OK
Definition: efuse5.h:184
EFUSE5_CURRENT_LIMIT_1550_mA
@ EFUSE5_CURRENT_LIMIT_1550_mA
Definition: efuse5.h:172
efuse5_cfg_setup
void efuse5_cfg_setup(efuse5_cfg_t *cfg)
eFuse 5 configuration object setup function.