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
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 EFUSE2_AD5175_SHUTDOWN_BIT_MASK 0x01
74#define EFUSE2_AD5175_NORMAL_MODE 0x00
75#define EFUSE2_AD5175_SHUTDOWN_MODE 0x01
76
81#define EFUSE2_AD5175_CTRL_REG_BIT_MASK 0x0B
82#define EFUSE2_AD5175_FUSE_PROGRAM_SUCCESSFUL 0x00
83#define EFUSE2_AD5175_FUSE_PROGRAM_UNSUCCESSFUL 0x08
84#define EFUSE2_AD5175_WIPER_POS_FROZEN 0x00
85#define EFUSE2_AD5175_UPDATE_WIPER_POS 0x02
86#define EFUSE2_AD5175_50T_PROGRAM_DISABLED 0x00
87#define EFUSE2_AD5175_50T_PROGRAM_ENABLE 0x01
88
93#define EFUSE2_AD5175_COMMAND_NOP 0x00
94#define EFUSE2_AD5175_COMMAND_WRITE_RDAC 0x04
95#define EFUSE2_AD5175_COMMAND_READ_RDAC 0x08
96#define EFUSE2_AD5175_COMMAND_STORE_WIPER 0x0C
97#define EFUSE2_AD5175_COMMAND_SW_RESET 0x10
98#define EFUSE2_AD5175_COMMAND_READ_50TP 0x14
99#define EFUSE2_AD5175_COMMAND_READ_MEMORY 0x18
100#define EFUSE2_AD5175_COMMAND_WRITE_MEMORY 0x1C
101#define EFUSE2_AD5175_COMMAND_READ_CONTROL 0x20
102#define EFUSE2_AD5175_COMMAND_SW_SHUTDOWN 0x24
103
104#define EFUSE2_AD5241_RDAC0 0x00
105#define EFUSE2_AD5241_RDAC1 0x80
106#define EFUSE2_AD5241_NO_RESET 0x00
107#define EFUSE2_AD5241_RESET 0x40
108#define EFUSE2_AD5241_NO_SHUTDOWN 0x00
109#define EFUSE2_AD5241_SHUTDOWN 0x20
110#define EFUSE2_AD5241_O1_LOW 0x00
111#define EFUSE2_AD5241_O1_HIGH 0x10
112#define EFUSE2_AD5241_O2_LOW 0x00
113#define EFUSE2_AD5241_O2_HIGH 0x08
114
120#define EFUSE2_I2C_SLAVE_ADDRESS_AD5241_0 0x2C
121#define EFUSE2_I2C_SLAVE_ADDRESS_AD5241_1 0x2D
122#define EFUSE2_I2C_SLAVE_ADDRESS_AD5241_2 0x2E
123#define EFUSE2_I2C_SLAVE_ADDRESS_AD5241_3 0x2F
124#define EFUSE2_I2C_SLAVE_ADDRESS_AD5175_GND 0x2F
125#define EFUSE2_I2C_SLAVE_ADDRESS_AD5175_VCC 0x2C
126#define EFUSE2_I2C_SLAVE_ADDRESS_AD5175_NC 0x2E
127
132#define EFUSE2_FAULT 0x00
133#define EFUSE2_NO_FAULT 0x01
134
139#define EFUSE2_10_BIT 0x03FF
140#define EFUSE2_DUMMY 0x0000
141
142
143 // efuse2_set
144
159#define EFUSE2_MAP_MIKROBUS( cfg, mikrobus ) \
160 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
161 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
162 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
163 cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
164
165 // efuse2_map
166 // efuse2
167
172typedef struct
173{
174 // Output pins
175 digital_out_t rst;
177 // Input pins
178 digital_in_t flt;
180 // Modules
181 i2c_master_t i2c;
183 // I2C slave address
187} efuse2_t;
188
193typedef struct
194{
195 pin_name_t scl;
196 pin_name_t sda;
198 pin_name_t rst;
199 pin_name_t flt;
201 uint32_t i2c_speed;
206
211typedef struct
212{
213 uint8_t select_rdac;
218
220
225typedef enum
226{
228 EFUSE2_ERROR = -1
229
231
248
261err_t efuse2_init ( efuse2_t *ctx, efuse2_cfg_t *cfg );
262
276
290err_t efuse2_write_ad5241 ( efuse2_t *ctx, ad5241_instru_t cmd, uint8_t data_byte );
291
302
313
328err_t efuse2_set_operating_voltage ( efuse2_t *ctx, float voltage, float *min_voltage, float *max_voltage );
342err_t efuse2_write_ad5175 ( efuse2_t *ctx, uint8_t cmd, uint16_t data_byte );
343
365uint16_t efuse2_read_ad5175 ( efuse2_t *ctx, uint8_t cmd, uint8_t wiper_location );
366
376uint16_t efuse2_read_rdac ( efuse2_t *ctx );
377
390
402err_t efuse2_write_rdac ( efuse2_t *ctx, uint16_t data_byte );
403
416err_t efuse2_set_current_limit ( efuse2_t *ctx, float current );
417
430
443
456err_t efuse2_operating_mode ( efuse2_t *ctx, uint8_t mode );
457
468uint16_t efuse2_next_frame_read ( efuse2_t *ctx, uint8_t wiper_location );
469
480uint16_t efuse2_read_memory ( efuse2_t *ctx );
481
495
508uint8_t efuse2_get_fault ( efuse2_t *ctx );
509
510#ifdef __cplusplus
511}
512#endif
513#endif // EFUSE2_H
514
515 // efuse2
516
517// ------------------------------------------------------------------------ END
efuse2_return_value_t
eFuse 2 Click return value data.
Definition efuse2.h:226
@ EFUSE2_OK
Definition efuse2.h:227
@ EFUSE2_ERROR
Definition efuse2.h:228
void efuse2_hw_reset(efuse2_t *ctx)
Hardware reset function.
err_t efuse2_set_current_limit(efuse2_t *ctx, float current)
Set operating current function.
err_t efuse2_write_rdac(efuse2_t *ctx, uint16_t data_byte)
Write RDAC function.
err_t efuse2_set_operating_voltage(efuse2_t *ctx, float voltage, float *min_voltage, float *max_voltage)
Set operating voltage function.
uint16_t efuse2_read_rdac(efuse2_t *ctx)
Read RDAC function.
err_t efuse2_sw_reset(efuse2_t *ctx)
Software reset function.
err_t efuse2_init(efuse2_t *ctx, efuse2_cfg_t *cfg)
eFuse 2 initialization function.
uint16_t efuse2_read_memory(efuse2_t *ctx)
Read memory function.
uint16_t efuse2_read_ad5175(efuse2_t *ctx, uint8_t cmd, uint8_t wiper_location)
Generic read data from the AD5175 function.
err_t efuse2_store_wiper(efuse2_t *ctx)
Store wiper setting function.
uint8_t efuse2_read_ad5241(efuse2_t *ctx)
Generic read data from the AD5241 function.
uint16_t efuse2_next_frame_read(efuse2_t *ctx, uint8_t wiper_location)
Next frame read function.
void efuse2_cfg_setup(efuse2_cfg_t *cfg)
eFuse 2 configuration object setup function.
uint8_t efuse2_get_fault(efuse2_t *ctx)
Get fault function.
err_t efuse2_write_ad5241(efuse2_t *ctx, ad5241_instru_t cmd, uint8_t data_byte)
Generic write data to the AD5241 function.
err_t efuse2_default_cfg(efuse2_t *ctx)
eFuse 2 default configuration function.
err_t efuse2_enable_write(efuse2_t *ctx)
Enable write function.
uint8_t efuse2_read_control(efuse2_t *ctx)
Read control register function.
err_t efuse2_operating_mode(efuse2_t *ctx, uint8_t mode)
Set operating mode function.
err_t efuse2_write_ad5175(efuse2_t *ctx, uint8_t cmd, uint16_t data_byte)
Generic write data to the AD5175 function.
float max_voltage
Definition main.c:41
float min_voltage
Definition main.c:40
eFuse 2 Click instruction object.
Definition efuse2.h:212
uint8_t output_logic_pin_2
Definition efuse2.h:217
uint8_t midscale_reset
Definition efuse2.h:214
uint8_t active_shutdown
Definition efuse2.h:215
uint8_t select_rdac
Definition efuse2.h:213
uint8_t output_logic_pin_1
Definition efuse2.h:216
eFuse 2 Click configuration object.
Definition efuse2.h:194
uint8_t i2c_address_ad5175
Definition efuse2.h:202
uint32_t i2c_speed
Definition efuse2.h:201
uint8_t i2c_address_ad5241
Definition efuse2.h:203
pin_name_t flt
Definition efuse2.h:199
pin_name_t scl
Definition efuse2.h:195
pin_name_t sda
Definition efuse2.h:196
pin_name_t rst
Definition efuse2.h:198
eFuse 2 Click context object.
Definition efuse2.h:173
digital_in_t flt
Definition efuse2.h:178
uint8_t slave_address_ad5241
Definition efuse2.h:185
uint8_t slave_address_ad5175
Definition efuse2.h:184
i2c_master_t i2c
Definition efuse2.h:181
digital_out_t rst
Definition efuse2.h:175