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 
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 EFUSE5_WRITE_TO_RDAC 0x00
74 #define EFUSE5_ONE_TIME_PROG 0x80
75 
76  // efuse5_inst
78 
93 #define EFUSE5_OTP_V_READY 0x00
94 #define EFUSE5_OTP_V_TEST_FUSE_OK 0x40
95 #define EFUSE5_OTP_V_ERROR 0x80
96 #define EFUSE5_OTP_V_PROG_SUCCESS 0xC0
97 
103 #define EFUSE5_DEVICE_ADDRESS 0x2C
104  // efuse5_set
106 
121 #define EFUSE5_MAP_MIKROBUS( cfg, mikrobus ) \
122  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
123  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
124  cfg.mon = MIKROBUS( mikrobus, MIKROBUS_AN ); \
125  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
126  cfg.pgd = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
127  cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
128  // efuse5_map // efuse5
131 
136 typedef struct
137 {
138  // Output pins
139  digital_out_t en;
141  // Input pins
142  digital_in_t mon;
143  digital_in_t pgd;
144  digital_in_t flt;
146  // Modules
147  i2c_master_t i2c;
149  // I2C slave address
150  uint8_t slave_address;
152 } efuse5_t;
153 
158 typedef struct
159 {
160  pin_name_t scl;
161  pin_name_t sda;
163  pin_name_t mon;
164  pin_name_t en;
165  pin_name_t pgd;
166  pin_name_t flt;
168  uint32_t i2c_speed;
169  uint8_t i2c_address;
171 } efuse5_cfg_t;
172 
177 typedef enum
178 {
189 
191 
196 typedef enum
197 {
199  EFUSE5_ERROR = -1
200 
202 
219 
233 err_t efuse5_init ( efuse5_t *ctx, efuse5_cfg_t *cfg );
234 
248 
262 err_t efuse5_write_byte ( efuse5_t *ctx, uint8_t inst, uint8_t data_in );
263 
276 err_t efuse5_generic_read ( efuse5_t *ctx, uint8_t *data_out );
277 
291 err_t efuse5_write_rdac ( efuse5_t *ctx, uint8_t rdac_data );
292 
306 err_t efuse5_read_rdac ( efuse5_t *ctx, uint8_t *rdac_data );
307 
321 err_t efuse5_set_digi_pot ( efuse5_t *ctx, uint8_t wiper_pos );
322 
337 err_t efuse5_set_resistance ( efuse5_t *ctx, uint16_t res_ohm );
338 
353 
366 
378 void efuse5_shutdown ( efuse5_t *ctx );
379 
390 uint8_t efuse5_get_imon ( efuse5_t *ctx );
391 
403 uint8_t efuse5_get_pgood ( efuse5_t *ctx );
404 
416 uint8_t efuse5_get_fault ( efuse5_t *ctx );
417 
418 #ifdef __cplusplus
419 }
420 #endif
421 #endif // EFUSE5_H
422  // efuse5
424 
425 // ------------------------------------------------------------------------ END
efuse5_cfg_t::mon
pin_name_t mon
Definition: efuse5.h:163
efuse5_t::flt
digital_in_t flt
Definition: efuse5.h:144
efuse5_cfg_t
eFuse 5 Click configuration object.
Definition: efuse5.h:159
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:165
efuse5_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: efuse5.h:168
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:143
EFUSE5_ERROR
@ EFUSE5_ERROR
Definition: efuse5.h:199
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:164
efuse5_t::en
digital_out_t en
Definition: efuse5.h:139
efuse5_cfg_t::flt
pin_name_t flt
Definition: efuse5.h:166
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:180
EFUSE5_CURRENT_LIMIT_4500_mA
@ EFUSE5_CURRENT_LIMIT_4500_mA
Definition: efuse5.h:188
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:178
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:197
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:183
EFUSE5_CURRENT_LIMIT_600_mA
@ EFUSE5_CURRENT_LIMIT_600_mA
Definition: efuse5.h:179
efuse5_t::slave_address
uint8_t slave_address
Definition: efuse5.h:150
efuse5_cfg_t::i2c_address
uint8_t i2c_address
Definition: efuse5.h:169
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:137
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:182
EFUSE5_CURRENT_LIMIT_2000_mA
@ EFUSE5_CURRENT_LIMIT_2000_mA
Definition: efuse5.h:187
efuse5_t::mon
digital_in_t mon
Definition: efuse5.h:142
efuse5_cfg_t::scl
pin_name_t scl
Definition: efuse5.h:160
EFUSE5_CURRENT_LIMIT_1445_mA
@ EFUSE5_CURRENT_LIMIT_1445_mA
Definition: efuse5.h:185
efuse5_cfg_t::sda
pin_name_t sda
Definition: efuse5.h:161
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:147
EFUSE5_CURRENT_LIMIT_1200_mA
@ EFUSE5_CURRENT_LIMIT_1200_mA
Definition: efuse5.h:184
EFUSE5_CURRENT_LIMIT_865_mA
@ EFUSE5_CURRENT_LIMIT_865_mA
Definition: efuse5.h:181
EFUSE5_OK
@ EFUSE5_OK
Definition: efuse5.h:198
EFUSE5_CURRENT_LIMIT_1550_mA
@ EFUSE5_CURRENT_LIMIT_1550_mA
Definition: efuse5.h:186
efuse5_cfg_setup
void efuse5_cfg_setup(efuse5_cfg_t *cfg)
eFuse 5 configuration object setup function.