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 "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define EFUSE5_WRITE_TO_RDAC 0x00
70 #define EFUSE5_ONE_TIME_PROG 0x80
71 
72  // efuse5_inst
74 
89 #define EFUSE5_OTP_V_READY 0x00
90 #define EFUSE5_OTP_V_TEST_FUSE_OK 0x40
91 #define EFUSE5_OTP_V_ERROR 0x80
92 #define EFUSE5_OTP_V_PROG_SUCCESS 0xC0
93 
99 #define EFUSE5_DEVICE_ADDRESS 0x2C
100  // efuse5_set
102 
117 #define EFUSE5_MAP_MIKROBUS( cfg, mikrobus ) \
118  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
119  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
120  cfg.mon = MIKROBUS( mikrobus, MIKROBUS_AN ); \
121  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
122  cfg.pgd = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
123  cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
124  // efuse5_map // efuse5
127 
132 typedef struct
133 {
134  // Output pins
135  digital_out_t en;
137  // Input pins
138  digital_in_t mon;
139  digital_in_t pgd;
140  digital_in_t flt;
142  // Modules
143  i2c_master_t i2c;
145  // I2C slave address
146  uint8_t slave_address;
148 } efuse5_t;
149 
154 typedef struct
155 {
156  pin_name_t scl;
157  pin_name_t sda;
159  pin_name_t mon;
160  pin_name_t en;
161  pin_name_t pgd;
162  pin_name_t flt;
164  uint32_t i2c_speed;
165  uint8_t i2c_address;
167 } efuse5_cfg_t;
168 
173 typedef enum
174 {
185 
187 
192 typedef enum
193 {
195  EFUSE5_ERROR = -1
196 
198 
215 
229 err_t efuse5_init ( efuse5_t *ctx, efuse5_cfg_t *cfg );
230 
244 
258 err_t efuse5_write_byte ( efuse5_t *ctx, uint8_t inst, uint8_t data_in );
259 
272 err_t efuse5_generic_read ( efuse5_t *ctx, uint8_t *data_out );
273 
287 err_t efuse5_write_rdac ( efuse5_t *ctx, uint8_t rdac_data );
288 
302 err_t efuse5_read_rdac ( efuse5_t *ctx, uint8_t *rdac_data );
303 
317 err_t efuse5_set_digi_pot ( efuse5_t *ctx, uint8_t wiper_pos );
318 
333 err_t efuse5_set_resistance ( efuse5_t *ctx, uint16_t res_ohm );
334 
349 
362 
374 void efuse5_shutdown ( efuse5_t *ctx );
375 
386 uint8_t efuse5_get_imon ( efuse5_t *ctx );
387 
399 uint8_t efuse5_get_pgood ( efuse5_t *ctx );
400 
412 uint8_t efuse5_get_fault ( efuse5_t *ctx );
413 
414 #ifdef __cplusplus
415 }
416 #endif
417 #endif // EFUSE5_H
418  // efuse5
420 
421 // ------------------------------------------------------------------------ END
efuse5_cfg_t::mon
pin_name_t mon
Definition: efuse5.h:159
efuse5_t::flt
digital_in_t flt
Definition: efuse5.h:140
efuse5_cfg_t
eFuse 5 Click configuration object.
Definition: efuse5.h:155
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:161
efuse5_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: efuse5.h:164
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:139
EFUSE5_ERROR
@ EFUSE5_ERROR
Definition: efuse5.h:195
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:160
efuse5_t::en
digital_out_t en
Definition: efuse5.h:135
efuse5_cfg_t::flt
pin_name_t flt
Definition: efuse5.h:162
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:176
EFUSE5_CURRENT_LIMIT_4500_mA
@ EFUSE5_CURRENT_LIMIT_4500_mA
Definition: efuse5.h:184
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:174
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:193
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:179
EFUSE5_CURRENT_LIMIT_600_mA
@ EFUSE5_CURRENT_LIMIT_600_mA
Definition: efuse5.h:175
efuse5_t::slave_address
uint8_t slave_address
Definition: efuse5.h:146
efuse5_cfg_t::i2c_address
uint8_t i2c_address
Definition: efuse5.h:165
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:133
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:178
EFUSE5_CURRENT_LIMIT_2000_mA
@ EFUSE5_CURRENT_LIMIT_2000_mA
Definition: efuse5.h:183
efuse5_t::mon
digital_in_t mon
Definition: efuse5.h:138
efuse5_cfg_t::scl
pin_name_t scl
Definition: efuse5.h:156
EFUSE5_CURRENT_LIMIT_1445_mA
@ EFUSE5_CURRENT_LIMIT_1445_mA
Definition: efuse5.h:181
efuse5_cfg_t::sda
pin_name_t sda
Definition: efuse5.h:157
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:143
EFUSE5_CURRENT_LIMIT_1200_mA
@ EFUSE5_CURRENT_LIMIT_1200_mA
Definition: efuse5.h:180
EFUSE5_CURRENT_LIMIT_865_mA
@ EFUSE5_CURRENT_LIMIT_865_mA
Definition: efuse5.h:177
EFUSE5_OK
@ EFUSE5_OK
Definition: efuse5.h:194
EFUSE5_CURRENT_LIMIT_1550_mA
@ EFUSE5_CURRENT_LIMIT_1550_mA
Definition: efuse5.h:182
efuse5_cfg_setup
void efuse5_cfg_setup(efuse5_cfg_t *cfg)
eFuse 5 configuration object setup function.