efuse2  2.0.0.0
efuse2.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2021 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 EFUSE2_H
29 #define EFUSE2_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 EFUSE2_AD5175_SHUTDOWN_BIT_MASK 0x01
60 #define EFUSE2_AD5175_NORMAL_MODE 0x00
61 #define EFUSE2_AD5175_SHUTDOWN_MODE 0x01
62 
67 #define EFUSE2_AD5175_CTRL_REG_BIT_MASK 0x0B
68 #define EFUSE2_AD5175_FUSE_PROGRAM_SUCCESSFUL 0x00
69 #define EFUSE2_AD5175_FUSE_PROGRAM_UNSUCCESSFUL 0x08
70 #define EFUSE2_AD5175_WIPER_POS_FROZEN 0x00
71 #define EFUSE2_AD5175_UPDATE_WIPER_POS 0x02
72 #define EFUSE2_AD5175_50T_PROGRAM_DISABLED 0x00
73 #define EFUSE2_AD5175_50T_PROGRAM_ENABLE 0x01
74 
79 #define EFUSE2_AD5175_COMMAND_NOP 0x00
80 #define EFUSE2_AD5175_COMMAND_WRITE_RDAC 0x04
81 #define EFUSE2_AD5175_COMMAND_READ_RDAC 0x08
82 #define EFUSE2_AD5175_COMMAND_STORE_WIPER 0x0C
83 #define EFUSE2_AD5175_COMMAND_SW_RESET 0x10
84 #define EFUSE2_AD5175_COMMAND_READ_50TP 0x14
85 #define EFUSE2_AD5175_COMMAND_READ_MEMORY 0x18
86 #define EFUSE2_AD5175_COMMAND_WRITE_MEMORY 0x1C
87 #define EFUSE2_AD5175_COMMAND_READ_CONTROL 0x20
88 #define EFUSE2_AD5175_COMMAND_SW_SHUTDOWN 0x24
89 
90 #define EFUSE2_AD5241_RDAC0 0x00
91 #define EFUSE2_AD5241_RDAC1 0x80
92 #define EFUSE2_AD5241_NO_RESET 0x00
93 #define EFUSE2_AD5241_RESET 0x40
94 #define EFUSE2_AD5241_NO_SHUTDOWN 0x00
95 #define EFUSE2_AD5241_SHUTDOWN 0x20
96 #define EFUSE2_AD5241_O1_LOW 0x00
97 #define EFUSE2_AD5241_O1_HIGH 0x10
98 #define EFUSE2_AD5241_O2_LOW 0x00
99 #define EFUSE2_AD5241_O2_HIGH 0x08
100 
106 #define EFUSE2_I2C_SLAVE_ADDRESS_AD5241_0 0x2C
107 #define EFUSE2_I2C_SLAVE_ADDRESS_AD5241_1 0x2D
108 #define EFUSE2_I2C_SLAVE_ADDRESS_AD5241_2 0x2E
109 #define EFUSE2_I2C_SLAVE_ADDRESS_AD5241_3 0x2F
110 #define EFUSE2_I2C_SLAVE_ADDRESS_AD5175_GND 0x2F
111 #define EFUSE2_I2C_SLAVE_ADDRESS_AD5175_VCC 0x2C
112 #define EFUSE2_I2C_SLAVE_ADDRESS_AD5175_NC 0x2E
113 
118 #define EFUSE2_FAULT 0x00
119 #define EFUSE2_NO_FAULT 0x01
120 
125 #define EFUSE2_10_BIT 0x03FF
126 #define EFUSE2_DUMMY 0x0000
127 
128  // efuse2_set
130 
145 #define EFUSE2_MAP_MIKROBUS( cfg, mikrobus ) \
146  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
147  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
148  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
149  cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
150  // efuse2_map // efuse2
153 
158 typedef struct
159 {
160  // Output pins
161  digital_out_t rst;
163  // Input pins
164  digital_in_t flt;
166  // Modules
167  i2c_master_t i2c;
169  // I2C slave address
173 } efuse2_t;
174 
179 typedef struct
180 {
181  pin_name_t scl;
182  pin_name_t sda;
184  pin_name_t rst;
185  pin_name_t flt;
187  uint32_t i2c_speed;
191 } efuse2_cfg_t;
192 
197 typedef struct
198 {
199  uint8_t select_rdac;
200  uint8_t midscale_reset;
204 
206 
211 typedef enum
212 {
214  EFUSE2_ERROR = -1
215 
217 
234 
247 err_t efuse2_init ( efuse2_t *ctx, efuse2_cfg_t *cfg );
248 
262 
276 err_t efuse2_write_ad5241 ( efuse2_t *ctx, ad5241_instru_t cmd, uint8_t data_byte );
277 
287 uint8_t efuse2_read_ad5241 ( efuse2_t *ctx );
288 
298 void efuse2_hw_reset ( efuse2_t *ctx );
299 
314 err_t efuse2_set_operating_voltage ( efuse2_t *ctx, float voltage, float *min_voltage, float *max_voltage );
328 err_t efuse2_write_ad5175 ( efuse2_t *ctx, uint8_t cmd, uint16_t data_byte );
329 
351 uint16_t efuse2_read_ad5175 ( efuse2_t *ctx, uint8_t cmd, uint8_t wiper_location );
352 
362 uint16_t efuse2_read_rdac ( efuse2_t *ctx );
363 
376 
388 err_t efuse2_write_rdac ( efuse2_t *ctx, uint16_t data_byte );
389 
402 err_t efuse2_set_current_limit ( efuse2_t *ctx, float current );
403 
415 err_t efuse2_sw_reset ( efuse2_t *ctx );
416 
429 
442 err_t efuse2_operating_mode ( efuse2_t *ctx, uint8_t mode );
443 
454 uint16_t efuse2_next_frame_read ( efuse2_t *ctx, uint8_t wiper_location );
455 
466 uint16_t efuse2_read_memory ( efuse2_t *ctx );
467 
480 uint8_t efuse2_read_control ( efuse2_t *ctx );
481 
494 uint8_t efuse2_get_fault ( efuse2_t *ctx );
495 
496 #ifdef __cplusplus
497 }
498 #endif
499 #endif // EFUSE2_H
500  // efuse2
502 
503 // ------------------------------------------------------------------------ END
ad5241_instru_t::select_rdac
uint8_t select_rdac
Definition: efuse2.h:199
efuse2_enable_write
err_t efuse2_enable_write(efuse2_t *ctx)
Enable write function.
efuse2_store_wiper
err_t efuse2_store_wiper(efuse2_t *ctx)
Store wiper setting function.
ad5241_instru_t::midscale_reset
uint8_t midscale_reset
Definition: efuse2.h:200
efuse2_read_ad5241
uint8_t efuse2_read_ad5241(efuse2_t *ctx)
Generic read data from the AD5241 function.
efuse2_cfg_t
eFuse 2 Click configuration object.
Definition: efuse2.h:180
efuse2_cfg_setup
void efuse2_cfg_setup(efuse2_cfg_t *cfg)
eFuse 2 configuration object setup function.
min_voltage
float min_voltage
Definition: main.c:40
efuse2_t::flt
digital_in_t flt
Definition: efuse2.h:164
ad5241_instru_t::output_logic_pin_1
uint8_t output_logic_pin_1
Definition: efuse2.h:202
efuse2_t::slave_address_ad5175
uint8_t slave_address_ad5175
Definition: efuse2.h:170
efuse2_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: efuse2.h:187
efuse2_cfg_t::sda
pin_name_t sda
Definition: efuse2.h:182
ad5241_instru_t::active_shutdown
uint8_t active_shutdown
Definition: efuse2.h:201
efuse2_operating_mode
err_t efuse2_operating_mode(efuse2_t *ctx, uint8_t mode)
Set operating mode function.
efuse2_sw_reset
err_t efuse2_sw_reset(efuse2_t *ctx)
Software reset function.
ad5241_instru_t::output_logic_pin_2
uint8_t output_logic_pin_2
Definition: efuse2.h:203
efuse2_cfg_t::rst
pin_name_t rst
Definition: efuse2.h:184
efuse2_default_cfg
err_t efuse2_default_cfg(efuse2_t *ctx)
eFuse 2 default configuration function.
efuse2_t::rst
digital_out_t rst
Definition: efuse2.h:161
EFUSE2_OK
@ EFUSE2_OK
Definition: efuse2.h:213
ad5241_instru_t
eFuse 2 Click instruction object.
Definition: efuse2.h:198
efuse2_cfg_t::scl
pin_name_t scl
Definition: efuse2.h:181
efuse2_t::i2c
i2c_master_t i2c
Definition: efuse2.h:167
efuse2_set_operating_voltage
err_t efuse2_set_operating_voltage(efuse2_t *ctx, float voltage, float *min_voltage, float *max_voltage)
Set operating voltage function.
max_voltage
float max_voltage
Definition: main.c:41
efuse2_cfg_t::i2c_address_ad5241
uint8_t i2c_address_ad5241
Definition: efuse2.h:189
EFUSE2_ERROR
@ EFUSE2_ERROR
Definition: efuse2.h:214
efuse2_cfg_t::i2c_address_ad5175
uint8_t i2c_address_ad5175
Definition: efuse2.h:188
efuse2_next_frame_read
uint16_t efuse2_next_frame_read(efuse2_t *ctx, uint8_t wiper_location)
Next frame read function.
efuse2_get_fault
uint8_t efuse2_get_fault(efuse2_t *ctx)
Get fault function.
efuse2_read_memory
uint16_t efuse2_read_memory(efuse2_t *ctx)
Read memory function.
efuse2_write_rdac
err_t efuse2_write_rdac(efuse2_t *ctx, uint16_t data_byte)
Write RDAC function.
efuse2_return_value_t
efuse2_return_value_t
eFuse 2 Click return value data.
Definition: efuse2.h:212
efuse2_cfg_t::flt
pin_name_t flt
Definition: efuse2.h:185
efuse2_hw_reset
void efuse2_hw_reset(efuse2_t *ctx)
Hardware reset function.
efuse2_read_control
uint8_t efuse2_read_control(efuse2_t *ctx)
Read control register function.
efuse2_t::slave_address_ad5241
uint8_t slave_address_ad5241
Definition: efuse2.h:171
efuse2_init
err_t efuse2_init(efuse2_t *ctx, efuse2_cfg_t *cfg)
eFuse 2 initialization function.
efuse2_t
eFuse 2 Click context object.
Definition: efuse2.h:159
efuse2_write_ad5241
err_t efuse2_write_ad5241(efuse2_t *ctx, ad5241_instru_t cmd, uint8_t data_byte)
Generic write data to the AD5241 function.
efuse2_read_ad5175
uint16_t efuse2_read_ad5175(efuse2_t *ctx, uint8_t cmd, uint8_t wiper_location)
Generic read data from the AD5175 function.
efuse2_set_current_limit
err_t efuse2_set_current_limit(efuse2_t *ctx, float current)
Set operating current function.
efuse2_write_ad5175
err_t efuse2_write_ad5175(efuse2_t *ctx, uint8_t cmd, uint16_t data_byte)
Generic write data to the AD5175 function.
efuse2_read_rdac
uint16_t efuse2_read_rdac(efuse2_t *ctx)
Read RDAC function.