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
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_spi_master.h"
38 
59 #define EFUSE3_OVERFLOW_LOW 2
60 #define EFUSE3_OVERFLOW_HIGH 1
61 #define EFUSE3_NO_OVERFLOW 0
62  // efuse3_set
64 
74 #define EFUSE3_VC_SEL_6_1_V 0
75 #define EFUSE3_VC_SEL_6_9_V 1
76  // vc_sel
78 
88 #define EFUSE3_FLAG_NORMAL_OPERATION 0
89 #define EFUSE3_FLAG_DEVICE_OFF 1
90  // efuse3_get
92 
107 #define EFUSE3_MAP_MIKROBUS( cfg, mikrobus ) \
108  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
109  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
110  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
111  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
112  cfg.vsel = MIKROBUS( mikrobus, MIKROBUS_RST ); \
113  cfg.en = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
114  cfg.flag = MIKROBUS( mikrobus, MIKROBUS_INT )
115  // efuse3_map // efuse3
118 
123 typedef struct
124 {
125  // Output pins
126 
127  digital_out_t vsel;
128  digital_out_t en;
130  // Input pins
131 
132  digital_in_t flag;
134  // Modules
135 
136  spi_master_t spi;
138  pin_name_t chip_select;
140 } efuse3_t;
141 
146 typedef struct
147 {
148  // Communication gpio pins
149 
150  pin_name_t miso;
151  pin_name_t mosi;
152  pin_name_t sck;
153  pin_name_t cs;
155  // Additional gpio pins
156 
157  pin_name_t vsel;
158  pin_name_t en;
159  pin_name_t flag;
161  // static variable
162 
163  uint32_t spi_speed;
164  spi_master_mode_t spi_mode;
165  spi_master_chip_select_polarity_t cs_polarity;
167 } efuse3_cfg_t;
168 
173 typedef enum
174 {
176  EFUSE3_ERROR = -1
177 
179 
195 void efuse3_cfg_setup ( efuse3_cfg_t *cfg );
196 
211 err_t efuse3_init ( efuse3_t *ctx, efuse3_cfg_t *cfg );
212 
223 void efuse3_default_cfg ( efuse3_t *ctx );
224 
239 err_t efuse3_generic_read ( efuse3_t *ctx, uint8_t *data_out, uint8_t len );
240 
256 err_t efuse3_get_monitor_output ( efuse3_t *ctx, float *voltage, uint8_t *overflow );
257 
271 err_t efuse3_get_current ( efuse3_t *ctx, float *current );
272 
285 void efuse3_enable_device ( efuse3_t *ctx );
286 
299 void efuse3_reset ( efuse3_t *ctx );
300 
313 void efuse3_disable_device ( efuse3_t *ctx );
314 
331 void efuse3_set_overvoltage_clamp ( efuse3_t *ctx, uint8_t vc_sel );
332 
350 uint8_t efuse3_get_flag ( efuse3_t *ctx );
351 
352 #ifdef __cplusplus
353 }
354 #endif
355 #endif // EFUSE3_H
356  // efuse3
358 
359 // ------------------------------------------------------------------------ END
efuse3_cfg_t
e Fuse 3 Click configuration object.
Definition: efuse3.h:145
efuse3_get_flag
uint8_t efuse3_get_flag(efuse3_t *ctx)
e Fuse 3 get flag function.
efuse3_init
err_t efuse3_init(efuse3_t *ctx, efuse3_cfg_t *cfg)
e Fuse 3 initialization function.
efuse3_set_overvoltage_clamp
void efuse3_set_overvoltage_clamp(efuse3_t *ctx, uint8_t vc_sel)
e Fuse 3 set overvoltage clamp function.
efuse3_return_value_t
efuse3_return_value_t
e Fuse 3 Click return value data.
Definition: efuse3.h:172
EFUSE3_ERROR
Definition: efuse3.h:175
efuse3_disable_device
void efuse3_disable_device(efuse3_t *ctx)
e Fuse 3 disable device function.
efuse3_reset
void efuse3_reset(efuse3_t *ctx)
e Fuse 3 reset function.
efuse3_t
e Fuse 3 Click context object.
Definition: efuse3.h:122
efuse3_generic_read
err_t efuse3_generic_read(efuse3_t *ctx, uint8_t *data_out, uint8_t len)
e Fuse 3 data reading function.
efuse3_cfg_setup
void efuse3_cfg_setup(efuse3_cfg_t *cfg)
e Fuse 3 configuration object setup function.
efuse3_get_current
err_t efuse3_get_current(efuse3_t *ctx, float *current)
e Fuse 3 get current function.
efuse3_get_monitor_output
err_t efuse3_get_monitor_output(efuse3_t *ctx, float *voltage, uint8_t *overflow)
e Fuse 3 get monitor output function.
EFUSE3_OK
Definition: efuse3.h:174
efuse3_enable_device
void efuse3_enable_device(efuse3_t *ctx)
e Fuse 3 enable device function.
efuse3_default_cfg
void efuse3_default_cfg(efuse3_t *ctx)
e Fuse 3 default configuration function.