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
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 EFUSE4_CMD_NOP 0x00
74#define EFUSE4_CMD_WRITE_RDAC 0x04
75#define EFUSE4_CMD_READ_RDAC 0x08
76#define EFUSE4_CMD_STORE_WIPER 0x0C
77#define EFUSE4_CMD_SW_RESET 0x10
78#define EFUSE4_CMD_READ_CONTENTS 0x14
79#define EFUSE4_CMD_READ_MEMORY 0x18
80#define EFUSE4_CMD_WRITE_MEMORY 0x1C
81#define EFUSE4_CMD_READ_CTRL 0x20
82#define EFUSE4_CMD_SW_SHUTDOWN 0x24
83
84 // efuse4_com
85
100#define EFUSE4_SET_SHUTDOWN_BIT_MASK 0x01
101#define EFUSE4_SET_NORMAL_MODE 0x00
102#define EFUSE4_SET_SHUTDOWN_MODE 0x01
103#define EFUSE4_SET_ENABLE_WRITE_MEMORY 0x0002
104
110#define EFUSE4_DEVICE_ADDRESS 0x2F
111
112 // efuse4_set
113
128#define EFUSE4_MAP_MIKROBUS( cfg, mikrobus ) \
129 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
130 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
131 cfg.pgd = MIKROBUS( mikrobus, MIKROBUS_AN ); \
132 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
133 cfg.dsv = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
134 cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
135
136 // efuse4_map
137 // efuse4
138
143typedef struct
144{
145 // Output pins
146 digital_out_t rst;
147 digital_out_t dsv;
149 // Input pins
150 digital_in_t pgd;
151 digital_in_t flt;
153 // Modules
154 i2c_master_t i2c;
156 // I2C slave address
159} efuse4_t;
160
165typedef struct
166{
167 pin_name_t scl;
168 pin_name_t sda;
170 pin_name_t pgd;
171 pin_name_t rst;
172 pin_name_t dsv;
173 pin_name_t flt;
175 uint32_t i2c_speed;
176 uint8_t i2c_address;
179
184typedef enum
185{
187 EFUSE4_ERROR = -1
188
190
206
223
237err_t efuse4_init ( efuse4_t *ctx, efuse4_cfg_t *cfg );
238
256
270err_t efuse4_generic_write ( efuse4_t *ctx, uint8_t cmd, uint16_t data_in );
271
286err_t efuse4_generic_read ( efuse4_t *ctx, uint8_t cmd, uint16_t data_in, uint16_t *data_out );
287
299
311
323
335
349
363
377err_t efuse4_write_rdac ( efuse4_t *ctx, uint16_t data_in );
378
392err_t efuse4_read_rdac ( efuse4_t *ctx, uint16_t *data_out );
393
407err_t efuse4_digi_pot_op_mode ( efuse4_t *ctx, uint8_t mode );
408
422
437err_t efuse4_next_frame_read ( efuse4_t *ctx, uint8_t wiper_location, uint16_t *data_out );
438
452err_t efuse4_read_memory ( efuse4_t *ctx, uint16_t *data_out );
453
467err_t efuse4_set_digi_pot ( efuse4_t *ctx, uint16_t wiper_pos );
468
482err_t efuse4_set_resistance ( efuse4_t *ctx, uint32_t res_ohm );
483
498
511
524
525#ifdef __cplusplus
526}
527#endif
528#endif // EFUSE4_H
529
530 // efuse4
531
532// ------------------------------------------------------------------------ END
efuse4_current_limit_t
eFuse 4 Click current limit value data.
Definition efuse4.h:196
@ EFUSE4_CURRENT_LIMIT_750_mA
Definition efuse4.h:198
@ EFUSE4_CURRENT_LIMIT_990_mA
Definition efuse4.h:199
@ EFUSE4_CURRENT_LIMIT_4450_mA
Definition efuse4.h:202
@ EFUSE4_CURRENT_LIMIT_2080_mA
Definition efuse4.h:200
@ EFUSE4_CURRENT_LIMIT_670_mA
Definition efuse4.h:197
@ EFUSE4_CURRENT_LIMIT_5200_mA
Definition efuse4.h:203
@ EFUSE4_CURRENT_LIMIT_3530_mA
Definition efuse4.h:201
efuse4_return_value_t
eFuse 4 Click return value data.
Definition efuse4.h:185
@ EFUSE4_ERROR
Definition efuse4.h:187
@ EFUSE4_OK
Definition efuse4.h:186
err_t efuse4_set_digi_pot(efuse4_t *ctx, uint16_t wiper_pos)
eFuse 4 set digital potentiometer function.
err_t efuse4_set_current_limit(efuse4_t *ctx, efuse4_current_limit_t current_limit)
eFuse 4 set current limit function.
err_t efuse4_sw_reset(efuse4_t *ctx)
eFuse 4 software reset function.
err_t efuse4_next_frame_read(efuse4_t *ctx, uint8_t wiper_location, uint16_t *data_out)
eFuse 4 next frame read function.
err_t efuse4_init(efuse4_t *ctx, efuse4_cfg_t *cfg)
eFuse 4 initialization function.
uint8_t efuse4_fault_state(efuse4_t *ctx)
eFuse 4 get fault state function.
void efuse4_set_disable(efuse4_t *ctx)
eFuse 4 disable function.
err_t efuse4_digi_pot_op_mode(efuse4_t *ctx, uint8_t mode)
eFuse 4 set digital potentiometer operation mode function.
err_t efuse4_generic_write(efuse4_t *ctx, uint8_t cmd, uint16_t data_in)
eFuse 4 I2C writing function.
void efuse4_cfg_setup(efuse4_cfg_t *cfg)
eFuse 4 configuration object setup function.
err_t efuse4_write_rdac(efuse4_t *ctx, uint16_t data_in)
eFuse 4 write RDAC function.
void efuse4_set_normal_mode(efuse4_t *ctx)
eFuse 4 set normal mode function.
err_t efuse4_default_cfg(efuse4_t *ctx)
eFuse 4 default configuration function.
err_t efuse4_generic_read(efuse4_t *ctx, uint8_t cmd, uint16_t data_in, uint16_t *data_out)
eFuse 4 I2C reading function.
err_t efuse4_store_wiper_pos(efuse4_t *ctx)
eFuse 4 store wiper function.
uint8_t efuse4_pwr_good_state(efuse4_t *ctx)
eFuse 4 get power good state function.
err_t efuse4_read_memory(efuse4_t *ctx, uint16_t *data_out)
eFuse 4 read memory function.
void efuse4_set_low_power_mode(efuse4_t *ctx)
eFuse 4 set low power mode function.
void efuse4_set_enable(efuse4_t *ctx)
eFuse 4 enable function.
err_t efuse4_set_resistance(efuse4_t *ctx, uint32_t res_ohm)
eFuse 4 set resistance function.
err_t efuse4_enable_write(efuse4_t *ctx)
eFuse 4 enable write function.
err_t efuse4_read_rdac(efuse4_t *ctx, uint16_t *data_out)
eFuse 4 read RDAC function.
eFuse 4 Click configuration object.
Definition efuse4.h:166
pin_name_t pgd
Definition efuse4.h:170
pin_name_t dsv
Definition efuse4.h:172
uint32_t i2c_speed
Definition efuse4.h:175
pin_name_t flt
Definition efuse4.h:173
pin_name_t scl
Definition efuse4.h:167
pin_name_t sda
Definition efuse4.h:168
pin_name_t rst
Definition efuse4.h:171
uint8_t i2c_address
Definition efuse4.h:176
eFuse 4 Click context object.
Definition efuse4.h:144
digital_in_t pgd
Definition efuse4.h:150
digital_in_t flt
Definition efuse4.h:151
digital_out_t dsv
Definition efuse4.h:147
i2c_master_t i2c
Definition efuse4.h:154
digital_out_t rst
Definition efuse4.h:146
uint8_t slave_address
Definition efuse4.h:157