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 
111 #define EFUSE2_I2C_SLAVE_ADDRESS_AD5175_GND 0x2F
112 #define EFUSE2_I2C_SLAVE_ADDRESS_AD5175_VCC 0x2C
113 #define EFUSE2_I2C_SLAVE_ADDRESS_AD5175_NC 0x2E
114 
119 #define EFUSE2_FAULT 0x00
120 #define EFUSE2_NO_FAULT 0x01
121 
126 #define EFUSE2_10_BIT 0x03FF
127 #define EFUSE2_DUMMY 0x0000
128 
129  // efuse2_set
131 
146 #define EFUSE2_MAP_MIKROBUS( cfg, mikrobus ) \
147  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
148  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
149  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
150  cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
151  // efuse2_map // efuse2
154 
159 typedef struct
160 {
161  // Output pins
162  digital_out_t rst;
164  // Input pins
165  digital_in_t flt;
167  // Modules
168  i2c_master_t i2c;
170  // I2C slave address
171  uint8_t 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;
188  uint8_t i2c_address;
190 } efuse2_cfg_t;
191 
196 typedef struct
197 {
198  uint8_t select_rdac;
199  uint8_t midscale_reset;
200  uint8_t active_shutdown;
201  uint8_t output_logic_pin_1;
202  uint8_t output_logic_pin_2;
204 
209 typedef enum
210 {
212  EFUSE2_ERROR = -1
213 
215 
231 void efuse2_cfg_setup ( efuse2_cfg_t *cfg );
232 
246 err_t efuse2_init ( efuse2_t *ctx, efuse2_cfg_t *cfg );
247 
261 err_t efuse2_default_cfg ( efuse2_t *ctx );
262 
277 err_t efuse2_generic_write ( efuse2_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
278 
293 err_t efuse2_generic_read ( efuse2_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
294 
295 
307 void efuse2_write_ad5241 ( efuse2_t *ctx, ad5241_instru_t cmd, uint8_t data_byte );
308 
318 uint8_t efuse2_read_ad5241 ( efuse2_t *ctx );
319 
329 void efuse2_hw_reset ( efuse2_t *ctx );
330 
343 void efuse2_set_operating_voltage ( efuse2_t *ctx, float voltage, float *min_voltage, float *max_voltage );
355 void efuse2_write_ad5175 ( efuse2_t *ctx, uint8_t cmd, uint16_t data_byte );
356 
378 uint16_t efuse2_read_ad5175 ( efuse2_t *ctx, uint8_t cmd, uint8_t wiper_location );
379 
389 uint16_t efuse2_read_rdac ( efuse2_t *ctx );
390 
400 void efuse2_enable_write ( efuse2_t *ctx );
401 
411 void efuse2_write_rdac ( efuse2_t *ctx, uint16_t data_byte );
412 
423 void efuse2_set_current_limit ( efuse2_t *ctx, float current );
424 
434 void efuse2_sw_reset ( efuse2_t *ctx );
435 
445 void efuse2_store_wiper ( efuse2_t *ctx );
446 
457 void efuse2_operating_mode ( efuse2_t *ctx, uint8_t mode );
458 
469 uint16_t efuse2_next_frame_read ( efuse2_t *ctx, uint8_t wiper_location );
470 
481 uint16_t efuse2_read_memory ( efuse2_t *ctx );
482 
495 uint8_t efuse2_read_control ( efuse2_t *ctx );
496 
509 uint8_t efuse2_get_fault ( efuse2_t *ctx );
510 
511 #ifdef __cplusplus
512 }
513 #endif
514 #endif // EFUSE2_H
515  // efuse2
517 
518 // ------------------------------------------------------------------------ END
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:178
efuse2_cfg_setup
void efuse2_cfg_setup(efuse2_cfg_t *cfg)
eFuse 2 configuration object setup function.
efuse2_enable_write
void efuse2_enable_write(efuse2_t *ctx)
Enable write function.
min_voltage
float min_voltage
Definition: main.c:40
efuse2_generic_read
err_t efuse2_generic_read(efuse2_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
eFuse 2 I2C reading function.
efuse2_write_rdac
void efuse2_write_rdac(efuse2_t *ctx, uint16_t data_byte)
Write RDAC function.
efuse2_generic_write
err_t efuse2_generic_write(efuse2_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
eFuse 2 I2C writing function.
efuse2_write_ad5241
void efuse2_write_ad5241(efuse2_t *ctx, ad5241_instru_t cmd, uint8_t data_byte)
Generic write data to the AD5241 function.
efuse2_write_ad5175
void efuse2_write_ad5175(efuse2_t *ctx, uint8_t cmd, uint16_t data_byte)
Generic write data to the AD5175 function.
efuse2_operating_mode
void efuse2_operating_mode(efuse2_t *ctx, uint8_t mode)
Set operating mode function.
efuse2_store_wiper
void efuse2_store_wiper(efuse2_t *ctx)
Store wiper setting function.
efuse2_default_cfg
err_t efuse2_default_cfg(efuse2_t *ctx)
eFuse 2 default configuration function.
EFUSE2_OK
Definition: efuse2.h:210
ad5241_instru_t
eFuse 2 Click instruction object.
Definition: efuse2.h:195
max_voltage
float max_voltage
Definition: main.c:41
EFUSE2_ERROR
Definition: efuse2.h:211
efuse2_set_operating_voltage
void efuse2_set_operating_voltage(efuse2_t *ctx, float voltage, float *min_voltage, float *max_voltage)
Set operating voltage function.
efuse2_set_current_limit
void efuse2_set_current_limit(efuse2_t *ctx, float current)
Set operating current function.
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_return_value_t
efuse2_return_value_t
eFuse 2 Click return value data.
Definition: efuse2.h:208
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_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:158
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_read_rdac
uint16_t efuse2_read_rdac(efuse2_t *ctx)
Read RDAC function.
efuse2_sw_reset
void efuse2_sw_reset(efuse2_t *ctx)
Software reset function.