39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
73#define FAN8_REG_TEMP_CH1 0x00
74#define FAN8_REG_TEMP_CH2 0x01
75#define FAN8_REG_CONFIG_BYTE 0x02
76#define FAN8_REG_CH1_OT_LIMIT 0x03
77#define FAN8_REG_CH2_OT_LIMIT 0x04
78#define FAN8_REG_OT_STATUS 0x05
79#define FAN8_REG_OT_MASK 0x06
80#define FAN8_REG_PWM1_START_DC 0x07
81#define FAN8_REG_PWM2_START_DC 0x08
82#define FAN8_REG_PWM1_MAX_DC 0x09
83#define FAN8_REG_PWM2_MAX_DC 0x0A
84#define FAN8_REG_PWM1_TARGET_DC 0x0B
85#define FAN8_REG_PWM2_TARGET_DC 0x0C
86#define FAN8_REG_PWM1_INSTANTANEOUS_DC 0x0D
87#define FAN8_REG_PWM2_INSTANTANEOUS_DC 0x0E
88#define FAN8_REG_CH1_FAN_START_TEMP 0x0F
89#define FAN8_REG_CH2_FAN_START_TEMP 0x10
90#define FAN8_REG_FAN_CONFIGURATION 0x11
91#define FAN8_REG_DC_ROC 0x12
92#define FAN8_REG_DC_STEP_SIZE 0x13
93#define FAN8_REG_PWM_FREQ_SEL 0x14
94#define FAN8_REG_THERMISTOR_OFFSET 0x17
95#define FAN8_REG_TACH1_VALUE 0x18
96#define FAN8_REG_TACH2_VALUE 0x19
97#define FAN8_REG_TACH1_LIMIT 0x1A
98#define FAN8_REG_TACH2_LIMIT 0x1B
99#define FAN8_REG_FAN_STATUS_BYTE 0x1C
100#define FAN8_REG_CH1_TEMP_LSB 0x1E
101#define FAN8_REG_CH2_TEMP_LSB 0x1F
102#define FAN8_REG_DEVICE_REV 0xFD
103#define FAN8_REG_DEVICE_ID 0xFE
104#define FAN8_REG_MANUFACTURER_ID 0xFF
122#define FAN8_DEVICE_ID 0x68
128#define FAN8_RESET 0x40
134#define FAN8_FAN_CHANNEL_1 0x01
135#define FAN8_FAN_CHANNEL_2 0x02
141#define FAN8_FAN_CHANNEL_1 0x01
142#define FAN8_FAN_CHANNEL_2 0x02
148#define FAN8_TEMP_CHANNEL_1 0x01
149#define FAN8_TEMP_CHANNEL_2 0x02
155#define FAN8_TEMPERATURE_RESOLUTION 0.125
161#define FAN8_MAX_DUTY_CYCLE 240
162#define FAN8_MIN_DUTY_CYCLE 0
163#define FAN8_DUTY_CYCLE_STEP_2 2
164#define FAN8_DUTY_CYCLE_STEP_4 4
165#define FAN8_DUTY_CYCLE_STEP_6 6
166#define FAN8_DUTY_CYCLE_STEP_8 8
167#define FAN8_DUTY_CYCLE_STEP_10 10
168#define FAN8_DUTY_CYCLE_STEP_12 12
169#define FAN8_DUTY_CYCLE_STEP_14 14
170#define FAN8_DUTY_CYCLE_STEP_16 16
176#define FAN8_CLOCK_COUNTER_FREQ 1950
177#define FAN8_SEC_PER_MIN 60
178#define FAN8_2_PULSES_PER_REVOLUTION 2
179#define FAN8_MAX_TACH_VALUE 255
186#define FAN8_DEV_ADDR_ADD0_GND_ADD1_GND 0x18
187#define FAN8_DEV_ADDR_ADD0_GND_ADD1_HIGH_Z 0x19
188#define FAN8_DEV_ADDR_ADD0_GND_ADD1_VCC 0x1A
189#define FAN8_DEV_ADDR_ADD0_HIGH_Z_ADD1_GND 0x29
190#define FAN8_DEV_ADDR_ADD0_HIGH_Z_ADD1_HIGH_Z 0x2A
191#define FAN8_DEV_ADDR_ADD0_HIGH_Z_ADD1_VCC 0x2B
192#define FAN8_DEV_ADDR_ADD0_VCC_ADD1_GND 0x4C
193#define FAN8_DEV_ADDR_ADD0_VCC_ADD1_HIGH_Z 0x4D
194#define FAN8_DEV_ADDR_ADD0_VCC_ADD1_VCC 0x4E
212#define FAN8_MAP_MIKROBUS( cfg, mikrobus ) \
213 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
214 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
215 cfg.ot = MIKROBUS( mikrobus, MIKROBUS_AN ); \
216 cfg.fan_fail = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
217 cfg.fault = MIKROBUS( mikrobus, MIKROBUS_INT )
fan8_return_value_t
FAN 8 Click return value data.
Definition fan8.h:264
@ FAN8_ERROR
Definition fan8.h:266
@ FAN8_OK
Definition fan8.h:265
err_t fan8_read_register(fan8_t *ctx, uint8_t reg, uint8_t *data_out)
FAN 8 read register function.
void fan8_cfg_setup(fan8_cfg_t *cfg)
FAN 8 configuration object setup function.
err_t fan8_write_register(fan8_t *ctx, uint8_t reg, uint8_t data_in)
FAN 8 write register function.
err_t fan8_read_temperature(fan8_t *ctx, uint8_t temp_ch, float *temperature)
FAN 8 read temperature function.
uint8_t fan8_check_overtemperature_indicator(fan8_t *ctx)
FAN 8 check overtemperature indicator function.
uint8_t fan8_check_fan_fail_indicator(fan8_t *ctx)
FAN 8 check fan fail indicator function.
err_t fan8_set_duty_cycle(fan8_t *ctx, uint8_t fan_ch, uint8_t duty_cycle)
FAN 8 set duty cycle function.
uint8_t fan8_check_fault_indicator(fan8_t *ctx)
FAN 8 check fault indicator function.
err_t fan8_measure_rpm(fan8_t *ctx, uint8_t fan_ch, uint8_t num_pulses, uint16_t *fan_rpm)
FAN 8 measure fan RPM function.
err_t fan8_default_cfg(fan8_t *ctx)
FAN 8 default configuration function.
err_t fan8_reset(fan8_t *ctx)
FAN 8 reset function.
err_t fan8_init(fan8_t *ctx, fan8_cfg_t *cfg)
FAN 8 initialization function.
err_t fan8_check_device_id(fan8_t *ctx)
FAN 8 check device ID function.
FAN 8 Click configuration object.
Definition fan8.h:246
uint32_t i2c_speed
Definition fan8.h:254
pin_name_t fan_fail
Definition fan8.h:251
pin_name_t scl
Definition fan8.h:247
pin_name_t sda
Definition fan8.h:248
pin_name_t ot
Definition fan8.h:250
pin_name_t fault
Definition fan8.h:252
uint8_t i2c_address
Definition fan8.h:255
FAN 8 Click context object.
Definition fan8.h:227
digital_in_t ot
Definition fan8.h:229
digital_in_t fan_fail
Definition fan8.h:230
i2c_master_t i2c
Definition fan8.h:234
digital_in_t fault
Definition fan8.h:231
uint8_t slave_address
Definition fan8.h:237