efuse3 2.0.0.0
efuse3.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 EFUSE3_H
29#define EFUSE3_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_spi_master.h"
52
73#define EFUSE3_OVERFLOW_LOW 2
74#define EFUSE3_OVERFLOW_HIGH 1
75#define EFUSE3_NO_OVERFLOW 0
76
77 // efuse3_set
78
88#define EFUSE3_VC_SEL_6_1_V 0
89#define EFUSE3_VC_SEL_6_9_V 1
90
91 // vc_sel
92
102#define EFUSE3_FLAG_NORMAL_OPERATION 0
103#define EFUSE3_FLAG_DEVICE_OFF 1
104
105 // efuse3_get
106
121#define EFUSE3_MAP_MIKROBUS( cfg, mikrobus ) \
122 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
123 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
124 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
125 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
126 cfg.vsel = MIKROBUS( mikrobus, MIKROBUS_RST ); \
127 cfg.en = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
128 cfg.flag = MIKROBUS( mikrobus, MIKROBUS_INT )
129
130 // efuse3_map
131 // efuse3
132
137typedef struct
138{
139 // Output pins
140
141 digital_out_t vsel;
142 digital_out_t en;
144 // Input pins
145
146 digital_in_t flag;
148 // Modules
149
150 spi_master_t spi;
152 pin_name_t chip_select;
154} efuse3_t;
155
160typedef struct
161{
162 // Communication gpio pins
163
164 pin_name_t miso;
165 pin_name_t mosi;
166 pin_name_t sck;
167 pin_name_t cs;
169 // Additional gpio pins
170
171 pin_name_t vsel;
172 pin_name_t en;
173 pin_name_t flag;
175 // static variable
176
177 uint32_t spi_speed;
178 spi_master_mode_t spi_mode;
179 spi_master_chip_select_polarity_t cs_polarity;
182
187typedef enum
188{
190 EFUSE3_ERROR = -1
191
193
210
225err_t efuse3_init ( efuse3_t *ctx, efuse3_cfg_t *cfg );
226
238
253err_t efuse3_generic_read ( efuse3_t *ctx, uint8_t *data_out, uint8_t len );
254
270err_t efuse3_get_monitor_output ( efuse3_t *ctx, float *voltage, uint8_t *overflow );
271
285err_t efuse3_get_current ( efuse3_t *ctx, float *current );
286
300
313void efuse3_reset ( efuse3_t *ctx );
314
328
345void efuse3_set_overvoltage_clamp ( efuse3_t *ctx, uint8_t vc_sel );
346
364uint8_t efuse3_get_flag ( efuse3_t *ctx );
365
366#ifdef __cplusplus
367}
368#endif
369#endif // EFUSE3_H
370
371 // efuse3
372
373// ------------------------------------------------------------------------ END
efuse3_return_value_t
e Fuse 3 Click return value data.
Definition efuse3.h:188
@ EFUSE3_ERROR
Definition efuse3.h:190
@ EFUSE3_OK
Definition efuse3.h:189
void efuse3_set_overvoltage_clamp(efuse3_t *ctx, uint8_t vc_sel)
e Fuse 3 set overvoltage clamp function.
void efuse3_reset(efuse3_t *ctx)
e Fuse 3 reset function.
err_t efuse3_generic_read(efuse3_t *ctx, uint8_t *data_out, uint8_t len)
e Fuse 3 data reading function.
err_t efuse3_get_monitor_output(efuse3_t *ctx, float *voltage, uint8_t *overflow)
e Fuse 3 get monitor output function.
uint8_t efuse3_get_flag(efuse3_t *ctx)
e Fuse 3 get flag function.
err_t efuse3_get_current(efuse3_t *ctx, float *current)
e Fuse 3 get current function.
err_t efuse3_init(efuse3_t *ctx, efuse3_cfg_t *cfg)
e Fuse 3 initialization function.
void efuse3_disable_device(efuse3_t *ctx)
e Fuse 3 disable device function.
void efuse3_default_cfg(efuse3_t *ctx)
e Fuse 3 default configuration function.
void efuse3_cfg_setup(efuse3_cfg_t *cfg)
e Fuse 3 configuration object setup function.
void efuse3_enable_device(efuse3_t *ctx)
e Fuse 3 enable device function.
e Fuse 3 Click configuration object.
Definition efuse3.h:161
pin_name_t vsel
Definition efuse3.h:171
spi_master_chip_select_polarity_t cs_polarity
Definition efuse3.h:179
pin_name_t sck
Definition efuse3.h:166
pin_name_t flag
Definition efuse3.h:173
spi_master_mode_t spi_mode
Definition efuse3.h:178
pin_name_t mosi
Definition efuse3.h:165
uint32_t spi_speed
Definition efuse3.h:177
pin_name_t en
Definition efuse3.h:172
pin_name_t miso
Definition efuse3.h:164
pin_name_t cs
Definition efuse3.h:167
e Fuse 3 Click context object.
Definition efuse3.h:138
spi_master_t spi
Definition efuse3.h:150
digital_out_t vsel
Definition efuse3.h:141
digital_in_t flag
Definition efuse3.h:146
digital_out_t en
Definition efuse3.h:142
pin_name_t chip_select
Definition efuse3.h:152