fan4 2.0.0.0
fan4.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef FAN4_H
36#define FAN4_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_i2c_master.h"
54
55// -------------------------------------------------------------- PUBLIC MACROS
65#define FAN4_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
67 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
74#define FAN4_RETVAL uint8_t
75
76#define FAN4_OK 0x00
77#define FAN4_INIT_ERROR 0xFF
84#define FAN4_SLAVE_ADDRESS 0x74
91#define FAN4_BOOST_START_TIMER_DIS 0x00
92#define FAN4_BOOST_START_TIMER_EN 0x01
99#define FAN4_VOLT_RANGE_CHECK_MASK 0x01
100#define FAN4_BS_TIMER_CHECK_MASK 0x02
101#define FAN4_THERM_SHTDWN_CHECK_MASK 0x40
102#define FAN4_OVERCURR_CHECK_MASK 0x80
103#define FAN4_CHECK_OK 0x00
110#define FAN4_DAC_LSB 78
111#define FAN4_MIN_VOLT_SCALE 0
112#define FAN4_MAX_VOLT_SCALE 4922
115 // End group macro
116// --------------------------------------------------------------- PUBLIC TYPES
125typedef struct
126{
127 // Modules
128
129 i2c_master_t i2c;
130
131 // ctx variable
132
134
135} fan4_t;
136
140typedef struct
141{
142 // Communication gpio pins
143
144 pin_name_t scl;
145 pin_name_t sda;
146
147 // static variable
148
149 uint32_t i2c_speed;
150 uint8_t i2c_address;
151
152} fan4_cfg_t;
153
154 // End types group
155// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
156
162#ifdef __cplusplus
163extern "C"{
164#endif
165
175
185
194
201void fan4_generic_write ( fan4_t *ctx, uint8_t cmd);
202
209void fan4_generic_read ( fan4_t *ctx, uint8_t *data_out );
210
218FAN4_RETVAL fan4_set_output ( fan4_t *ctx, uint16_t output_volt, uint8_t boost_start_timer );
219
227
228#ifdef __cplusplus
229}
230#endif
231#endif // _FAN4_H_
232
233 // End public_function group
235
236// ------------------------------------------------------------------------- END
#define FAN4_RETVAL
Definition fan4.h:74
uint8_t fan4_check_diagnostic(fan4_t *ctx)
Check diagnostic.
void fan4_default_cfg(fan4_t *ctx)
Click Default Configuration function.
FAN4_RETVAL fan4_set_output(fan4_t *ctx, uint16_t output_volt, uint8_t boost_start_timer)
Set output voltage.
void fan4_cfg_setup(fan4_cfg_t *cfg)
Config Object Initialization function.
void fan4_generic_write(fan4_t *ctx, uint8_t cmd)
Generic write function.
FAN4_RETVAL fan4_init(fan4_t *ctx, fan4_cfg_t *cfg)
Initialization function.
void fan4_generic_read(fan4_t *ctx, uint8_t *data_out)
Generic read function.
Click configuration structure definition.
Definition fan4.h:141
uint32_t i2c_speed
Definition fan4.h:149
pin_name_t scl
Definition fan4.h:144
pin_name_t sda
Definition fan4.h:145
uint8_t i2c_address
Definition fan4.h:150
Click ctx object definition.
Definition fan4.h:126
i2c_master_t i2c
Definition fan4.h:129
uint8_t slave_address
Definition fan4.h:133