efuse4  2.1.0.0
efuse4.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 EFUSE4_H
29 #define EFUSE4_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 EFUSE4_CMD_NOP 0x00
60 #define EFUSE4_CMD_WRITE_RDAC 0x04
61 #define EFUSE4_CMD_READ_RDAC 0x08
62 #define EFUSE4_CMD_STORE_WIPER 0x0C
63 #define EFUSE4_CMD_SW_RESET 0x10
64 #define EFUSE4_CMD_READ_CONTENTS 0x14
65 #define EFUSE4_CMD_READ_MEMORY 0x18
66 #define EFUSE4_CMD_WRITE_MEMORY 0x1C
67 #define EFUSE4_CMD_READ_CTRL 0x20
68 #define EFUSE4_CMD_SW_SHUTDOWN 0x24
69  // efuse4_com
71 
86 #define EFUSE4_SET_SHUTDOWN_BIT_MASK 0x01
87 #define EFUSE4_SET_NORMAL_MODE 0x00
88 #define EFUSE4_SET_SHUTDOWN_MODE 0x01
89 #define EFUSE4_SET_ENABLE_WRITE_MEMORY 0x0002
90 
96 #define EFUSE4_DEVICE_ADDRESS 0x2F
97  // efuse4_set
99 
114 #define EFUSE4_MAP_MIKROBUS( cfg, mikrobus ) \
115  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
116  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
117  cfg.pgd = MIKROBUS( mikrobus, MIKROBUS_AN ); \
118  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
119  cfg.dsv = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
120  cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
121  // efuse4_map // efuse4
124 
129 typedef struct
130 {
131  // Output pins
132  digital_out_t rst;
133  digital_out_t dsv;
135  // Input pins
136  digital_in_t pgd;
137  digital_in_t flt;
139  // Modules
140  i2c_master_t i2c;
142  // I2C slave address
143  uint8_t slave_address;
145 } efuse4_t;
146 
151 typedef struct
152 {
153  pin_name_t scl;
154  pin_name_t sda;
156  pin_name_t pgd;
157  pin_name_t rst;
158  pin_name_t dsv;
159  pin_name_t flt;
161  uint32_t i2c_speed;
162  uint8_t i2c_address;
164 } efuse4_cfg_t;
165 
170 typedef enum
171 {
173  EFUSE4_ERROR = -1
174 
176 
181 typedef enum
182 {
190 
192 
209 
223 err_t efuse4_init ( efuse4_t *ctx, efuse4_cfg_t *cfg );
224 
242 
256 err_t efuse4_generic_write ( efuse4_t *ctx, uint8_t cmd, uint16_t data_in );
257 
272 err_t efuse4_generic_read ( efuse4_t *ctx, uint8_t cmd, uint16_t data_in, uint16_t *data_out );
273 
285 
297 
309 
321 
334 err_t efuse4_sw_reset ( efuse4_t *ctx );
335 
349 
363 err_t efuse4_write_rdac ( efuse4_t *ctx, uint16_t data_in );
364 
378 err_t efuse4_read_rdac ( efuse4_t *ctx, uint16_t *data_out );
379 
393 err_t efuse4_digi_pot_op_mode ( efuse4_t *ctx, uint8_t mode );
394 
408 
423 err_t efuse4_next_frame_read ( efuse4_t *ctx, uint8_t wiper_location, uint16_t *data_out );
424 
438 err_t efuse4_read_memory ( efuse4_t *ctx, uint16_t *data_out );
439 
453 err_t efuse4_set_digi_pot ( efuse4_t *ctx, uint16_t wiper_pos );
454 
468 err_t efuse4_set_resistance ( efuse4_t *ctx, uint32_t res_ohm );
469 
484 
496 uint8_t efuse4_fault_state ( efuse4_t *ctx );
497 
510 
511 #ifdef __cplusplus
512 }
513 #endif
514 #endif // EFUSE4_H
515  // efuse4
517 
518 // ------------------------------------------------------------------------ END
efuse4_enable_write
err_t efuse4_enable_write(efuse4_t *ctx)
eFuse 4 enable write function.
efuse4_pwr_good_state
uint8_t efuse4_pwr_good_state(efuse4_t *ctx)
eFuse 4 get power good state function.
efuse4_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: efuse4.h:161
efuse4_cfg_t
eFuse 4 Click configuration object.
Definition: efuse4.h:152
EFUSE4_CURRENT_LIMIT_670_mA
@ EFUSE4_CURRENT_LIMIT_670_mA
Definition: efuse4.h:183
efuse4_fault_state
uint8_t efuse4_fault_state(efuse4_t *ctx)
eFuse 4 get fault state function.
efuse4_next_frame_read
err_t efuse4_next_frame_read(efuse4_t *ctx, uint8_t wiper_location, uint16_t *data_out)
eFuse 4 next frame read function.
efuse4_set_disable
void efuse4_set_disable(efuse4_t *ctx)
eFuse 4 disable function.
efuse4_set_normal_mode
void efuse4_set_normal_mode(efuse4_t *ctx)
eFuse 4 set normal mode function.
efuse4_write_rdac
err_t efuse4_write_rdac(efuse4_t *ctx, uint16_t data_in)
eFuse 4 write RDAC function.
efuse4_t::i2c
i2c_master_t i2c
Definition: efuse4.h:140
efuse4_digi_pot_op_mode
err_t efuse4_digi_pot_op_mode(efuse4_t *ctx, uint8_t mode)
eFuse 4 set digital potentiometer operation mode function.
EFUSE4_CURRENT_LIMIT_750_mA
@ EFUSE4_CURRENT_LIMIT_750_mA
Definition: efuse4.h:184
efuse4_generic_write
err_t efuse4_generic_write(efuse4_t *ctx, uint8_t cmd, uint16_t data_in)
eFuse 4 I2C writing function.
efuse4_cfg_t::rst
pin_name_t rst
Definition: efuse4.h:157
efuse4_set_current_limit
err_t efuse4_set_current_limit(efuse4_t *ctx, efuse4_current_limit_t current_limit)
eFuse 4 set current limit function.
efuse4_return_value_t
efuse4_return_value_t
eFuse 4 Click return value data.
Definition: efuse4.h:171
EFUSE4_ERROR
@ EFUSE4_ERROR
Definition: efuse4.h:173
efuse4_default_cfg
err_t efuse4_default_cfg(efuse4_t *ctx)
eFuse 4 default configuration function.
efuse4_cfg_t::sda
pin_name_t sda
Definition: efuse4.h:154
efuse4_read_rdac
err_t efuse4_read_rdac(efuse4_t *ctx, uint16_t *data_out)
eFuse 4 read RDAC function.
efuse4_current_limit_t
efuse4_current_limit_t
eFuse 4 Click current limit value data.
Definition: efuse4.h:182
efuse4_sw_reset
err_t efuse4_sw_reset(efuse4_t *ctx)
eFuse 4 software reset function.
efuse4_cfg_t::pgd
pin_name_t pgd
Definition: efuse4.h:156
efuse4_t::dsv
digital_out_t dsv
Definition: efuse4.h:133
efuse4_generic_read
err_t efuse4_generic_read(efuse4_t *ctx, uint8_t cmd, uint16_t data_in, uint16_t *data_out)
eFuse 4 I2C reading function.
EFUSE4_CURRENT_LIMIT_5200_mA
@ EFUSE4_CURRENT_LIMIT_5200_mA
Definition: efuse4.h:189
efuse4_set_enable
void efuse4_set_enable(efuse4_t *ctx)
eFuse 4 enable function.
efuse4_read_memory
err_t efuse4_read_memory(efuse4_t *ctx, uint16_t *data_out)
eFuse 4 read memory function.
efuse4_t::flt
digital_in_t flt
Definition: efuse4.h:137
EFUSE4_OK
@ EFUSE4_OK
Definition: efuse4.h:172
efuse4_init
err_t efuse4_init(efuse4_t *ctx, efuse4_cfg_t *cfg)
eFuse 4 initialization function.
efuse4_cfg_t::flt
pin_name_t flt
Definition: efuse4.h:159
efuse4_set_digi_pot
err_t efuse4_set_digi_pot(efuse4_t *ctx, uint16_t wiper_pos)
eFuse 4 set digital potentiometer function.
efuse4_cfg_t::i2c_address
uint8_t i2c_address
Definition: efuse4.h:162
EFUSE4_CURRENT_LIMIT_4450_mA
@ EFUSE4_CURRENT_LIMIT_4450_mA
Definition: efuse4.h:188
efuse4_t
eFuse 4 Click context object.
Definition: efuse4.h:130
efuse4_set_resistance
err_t efuse4_set_resistance(efuse4_t *ctx, uint32_t res_ohm)
eFuse 4 set resistance function.
efuse4_cfg_t::dsv
pin_name_t dsv
Definition: efuse4.h:158
efuse4_cfg_setup
void efuse4_cfg_setup(efuse4_cfg_t *cfg)
eFuse 4 configuration object setup function.
EFUSE4_CURRENT_LIMIT_990_mA
@ EFUSE4_CURRENT_LIMIT_990_mA
Definition: efuse4.h:185
efuse4_t::pgd
digital_in_t pgd
Definition: efuse4.h:136
efuse4_cfg_t::scl
pin_name_t scl
Definition: efuse4.h:153
EFUSE4_CURRENT_LIMIT_3530_mA
@ EFUSE4_CURRENT_LIMIT_3530_mA
Definition: efuse4.h:187
efuse4_store_wiper_pos
err_t efuse4_store_wiper_pos(efuse4_t *ctx)
eFuse 4 store wiper function.
EFUSE4_CURRENT_LIMIT_2080_mA
@ EFUSE4_CURRENT_LIMIT_2080_mA
Definition: efuse4.h:186
efuse4_set_low_power_mode
void efuse4_set_low_power_mode(efuse4_t *ctx)
eFuse 4 set low power mode function.
efuse4_t::slave_address
uint8_t slave_address
Definition: efuse4.h:143
efuse4_t::rst
digital_out_t rst
Definition: efuse4.h:132