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
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 EFUSE5_WRITE_TO_RDAC 0x00
74#define EFUSE5_ONE_TIME_PROG 0x80
75
76
77 // 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
105 // 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
129 // efuse5_map
130 // efuse5
131
136typedef 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
152} efuse5_t;
153
158typedef 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;
172
191
196typedef enum
197{
199 EFUSE5_ERROR = -1
200
202
219
233err_t efuse5_init ( efuse5_t *ctx, efuse5_cfg_t *cfg );
234
248
262err_t efuse5_write_byte ( efuse5_t *ctx, uint8_t inst, uint8_t data_in );
263
276err_t efuse5_generic_read ( efuse5_t *ctx, uint8_t *data_out );
277
291err_t efuse5_write_rdac ( efuse5_t *ctx, uint8_t rdac_data );
292
306err_t efuse5_read_rdac ( efuse5_t *ctx, uint8_t *rdac_data );
307
321err_t efuse5_set_digi_pot ( efuse5_t *ctx, uint8_t wiper_pos );
322
337err_t efuse5_set_resistance ( efuse5_t *ctx, uint16_t res_ohm );
338
353
366
379
390uint8_t efuse5_get_imon ( efuse5_t *ctx );
391
403uint8_t efuse5_get_pgood ( efuse5_t *ctx );
404
416uint8_t efuse5_get_fault ( efuse5_t *ctx );
417
418#ifdef __cplusplus
419}
420#endif
421#endif // EFUSE5_H
422
423 // efuse5
424
425// ------------------------------------------------------------------------ END
efuse5_return_value_t
eFuse 5 Click return value data.
Definition efuse5.h:197
@ EFUSE5_OK
Definition efuse5.h:198
@ EFUSE5_ERROR
Definition efuse5.h:199
efuse5_current_limit_t
eFuse 5 Click current limit value data.
Definition efuse5.h:178
@ EFUSE5_CURRENT_LIMIT_900_mA
Definition efuse5.h:182
@ EFUSE5_CURRENT_LIMIT_4500_mA
Definition efuse5.h:188
@ EFUSE5_CURRENT_LIMIT_720_mA
Definition efuse5.h:180
@ EFUSE5_CURRENT_LIMIT_2000_mA
Definition efuse5.h:187
@ EFUSE5_CURRENT_LIMIT_865_mA
Definition efuse5.h:181
@ EFUSE5_CURRENT_LIMIT_1550_mA
Definition efuse5.h:186
@ EFUSE5_CURRENT_LIMIT_1445_mA
Definition efuse5.h:185
@ EFUSE5_CURRENT_LIMIT_1030_mA
Definition efuse5.h:183
@ EFUSE5_CURRENT_LIMIT_1200_mA
Definition efuse5.h:184
@ EFUSE5_CURRENT_LIMIT_600_mA
Definition efuse5.h:179
void efuse5_enable_device(efuse5_t *ctx)
eFuse 5 enable the device function.
err_t efuse5_set_current_limit(efuse5_t *ctx, efuse5_current_limit_t current_limit)
eFuse 5 set the current limit function.
void efuse5_cfg_setup(efuse5_cfg_t *cfg)
eFuse 5 configuration object setup function.
err_t efuse5_set_resistance(efuse5_t *ctx, uint16_t res_ohm)
eFuse 5 set the resistance function.
uint8_t efuse5_get_fault(efuse5_t *ctx)
eFuse 5 gets fault condition state function.
err_t efuse5_read_rdac(efuse5_t *ctx, uint8_t *rdac_data)
eFuse 5 read RDAC function.
uint8_t efuse5_get_pgood(efuse5_t *ctx)
eFuse 5 gets power good state function.
uint8_t efuse5_get_imon(efuse5_t *ctx)
eFuse 5 get imon function.
err_t efuse5_init(efuse5_t *ctx, efuse5_cfg_t *cfg)
eFuse 5 initialization function.
err_t efuse5_write_rdac(efuse5_t *ctx, uint8_t rdac_data)
eFuse 5 write RDAC function.
err_t efuse5_write_byte(efuse5_t *ctx, uint8_t inst, uint8_t data_in)
eFuse 5 I2C writing function.
err_t efuse5_default_cfg(efuse5_t *ctx)
eFuse 5 default configuration function.
void efuse5_shutdown(efuse5_t *ctx)
eFuse 5 disable the device function.
err_t efuse5_set_digi_pot(efuse5_t *ctx, uint8_t wiper_pos)
eFuse 5 set the digital potentiometer function.
err_t efuse5_generic_read(efuse5_t *ctx, uint8_t *data_out)
eFuse 5 I2C reading function.
eFuse 5 Click configuration object.
Definition efuse5.h:159
pin_name_t pgd
Definition efuse5.h:165
uint32_t i2c_speed
Definition efuse5.h:168
pin_name_t flt
Definition efuse5.h:166
pin_name_t scl
Definition efuse5.h:160
pin_name_t en
Definition efuse5.h:164
pin_name_t sda
Definition efuse5.h:161
pin_name_t mon
Definition efuse5.h:163
uint8_t i2c_address
Definition efuse5.h:169
eFuse 5 Click context object.
Definition efuse5.h:137
digital_in_t pgd
Definition efuse5.h:143
digital_in_t mon
Definition efuse5.h:142
digital_in_t flt
Definition efuse5.h:144
i2c_master_t i2c
Definition efuse5.h:147
digital_out_t en
Definition efuse5.h:139
uint8_t slave_address
Definition efuse5.h:150