fan2 2.0.0.0
fan2.h File Reference

This file contains API for Fan 2 Click driver. More...

#include "drv_digital_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  fan2_t
 Click context object definition. More...
 
struct  fan2_cfg_t
 Click configuration structure definition. More...
 

Macros

#define FAN2_REG_CTRL1   0x0
 
#define FAN2_REG_CTRL2   0x1
 
#define FAN2_REG_CTRL3   0x2
 
#define FAN2_REG_FF_DUTY_CYCLE   0x3
 
#define FAN2_REG_ALERT_MASK   0x4
 
#define FAN2_REG_IDEALITY_FACTOR   0x5
 
#define FAN2_REG_REMOTE_HIGH_SETPOINT   0x6
 
#define FAN2_REG_LOCAL_OVERTEMP_SETPOINT   0x8
 
#define FAN2_REG_REMOTE_OVERTEMP_SETPOINT   0xA
 
#define FAN2_REG_LOCAL_HIGH_SETPOINT   0xC
 
#define FAN2_REG_TACH_CNT_THRSH   0xE
 
#define FAN2_REG_GENERAL_PURPOSE_FIRST_MEM   0x10
 
#define FAN2_REG_GENERAL_PURPOSE_LAST_MEM   0x17
 
#define FAN2_REG_LUT_START   0x20
 
#define FAN2_REG_LUT_END   0x4F
 
#define FAN2_REG_DIRECT_DUTY_CYCLE_CTRL   0x50
 
#define FAN2_REG_CURRENT_PWM_DUTY_CYCLE   0x51
 
#define FAN2_REG_TACH1_CNT   0x52
 
#define FAN2_REG_TACH2_CNT   0x54
 
#define FAN2_REG_REMOTE_TEMP_READ   0x56
 
#define FAN2_REG_LOCAL_TEMP_READ   0x58
 
#define FAN2_REG_STATUS   0x5A
 
#define FAN2_REG_EEPROM_TO_RAM   0x5B
 
#define FAN2_CTRL1_MASK_TEMP_ALERTS   0x80
 
#define FAN2_CTRL1_SW_POR   0x40
 
#define FAN2_CTRL1_LUT_HYST_2_CELS   0x0
 
#define FAN2_CTRL1_LUT_HYST_4_CELS   0x20
 
#define FAN2_CTRL1_PWM_FREQ_33_HZ   0x0
 
#define FAN2_CTRL1_PWM_FREQ_150_HZ   0x8
 
#define FAN2_CTRL1_PWM_FREQ_1500_HZ   0x10
 
#define FAN2_CTRL1_PWM_FREQ_25_KHZ   0x18
 
#define FAN2_CTRL1_PWM_POL_POS   0x0
 
#define FAN2_CTRL1_PWM_POL_NEG   0x4
 
#define FAN2_CTRL1_TEMP_IDX_TIS   0x0
 
#define FAN2_CTRL1_TEMP_IDX_GREATER   0x2
 
#define FAN2_CTRL1_LUT_IDX_LOCAL_TEMP   0x0
 
#define FAN2_CTRL1_LUT_IDX_REMOTE_TEMP   0x1
 
#define FAN2_CTRL2_NORMAL_MODE   0x0
 
#define FAN2_CTRL2_STANDBY_MODE   0x80
 
#define FAN2_CTRL2_ALERT_INTERR   0x0
 
#define FAN2_CTRL2_ALERT_COMP   0x40
 
#define FAN2_CTRL2_SPIN_UP_EN   0x20
 
#define FAN2_CTRL2_FF_OUTPUT_INTERR   0x0
 
#define FAN2_CTRL2_FF_OUTPUT_COMP   0x10
 
#define FAN2_CTRL2_FS_INPUT_EN   0x8
 
#define FAN2_CTRL2_RD_ACTIVE_LOW   0x0
 
#define FAN2_CTRL2_RD_ACTIVE_HIGH   0x4
 
#define FAN2_CTRL2_TACHO_SQUARE_WAVE   0x0
 
#define FAN2_CTRL2_TACHO_RD   0x2
 
#define FAN2_CTRL2_DIRECT_FAN_CTRL_EN   0x1
 
#define FAN2_CTRL3_CLR_FAIL   0x80
 
#define FAN2_CTRL3_FF_DETECT_EN   0x40
 
#define FAN2_CTRL3_PWM_RAMP_RATE_SLOW   0x0
 
#define FAN2_CTRL3_PWM_RAMP_RATE_SLOW_MEDIUM   0x10
 
#define FAN2_CTRL3_PWM_RAMP_RATE_MEDIUM_FAST   0x20
 
#define FAN2_CTRL3_PWM_RAMP_RATE_FAST   0x30
 
#define FAN2_CTRL3_TACHFULL_EN   0x8
 
#define FAN2_CTRL3_PULSE_STRETCH_EN   0x4
 
#define FAN2_CTRL3_TACH2_EN   0x2
 
#define FAN2_CTRL3_TACH1_EN   0x1
 
#define FAN2_MASK_ALARM_LOCAL_TEMP_HIGH   0x20
 
#define FAN2_MASK_ALARM_LOCAL_OVERTEMP   0x10
 
#define FAN2_MASK_ALARM_REMOTE_TEMP_HIGH   0x8
 
#define FAN2_MASK_ALARM_REMOTE_OVERTEMP   0x4
 
#define FAN2_MASK_ALARM_TACH2   0x2
 
#define FAN2_MASK_ALARM_TACH1   0x1
 
#define FAN2_MASK_ALARM_RESERVED_BITS   0xC0
 
#define FAN2_MASK_ALARM_NONE   0x0
 
#define FAN2_EEPROM_WRITE   0x0
 
#define FAN2_EEPROM_LOAD   0x80
 
#define FAN2_EEPROM_40H_TO_4FH   0x10
 
#define FAN2_EEPROM_30H_TO_3FH   0x8
 
#define FAN2_EEPROM_20H_TO_2FH   0x4
 
#define FAN2_EEPROM_10H_TO_1FH   0x2
 
#define FAN2_EEPROM_00H_TO_0FH   0x1
 
#define FAN2_TEMP_DATA_OFFSET   5
 
#define FAN2_TEMP_DATA_MASK   0xFFE0
 
#define FAN2_STAT_FLAG_PROGRAM_CORRUPT   0x80
 
#define FAN2_STAT_FLAG_REMOTE_DIODE_FAULT   0x40
 
#define FAN2_STAT_FLAG_LOCAL_HIGH_TEMP_ALARM   0x20
 
#define FAN2_STAT_FLAG_LOCAL_OVERTEMP_ALARM   0x10
 
#define FAN2_STAT_FLAG_REMOTE_HIGH_TEMP_ALARM   0x8
 
#define FAN2_STAT_FLAG_REMOTE_OVERTEMP_ALARM   0x4
 
#define FAN2_STAT_FLAG_TACH2_ALARM   0x2
 
#define FAN2_STAT_FLAG_TACH1_ALARM   0x1
 
#define FAN2_MAX_TEMP_CELS   125
 
#define FAN2_ZERO_TEMP_CELS   0
 
#define FAN2_MIN_TEMP_CELS   -55
 
#define FAN2_MAX_SPEED_PER   100
 
#define FAN2_HALF_SPEED_PER   50
 
#define FAN2_MIN_SPEED_PER   0
 
#define FAN2_LUT_NBYTES   48
 
#define FAN2_MAP_MIKROBUS(cfg, mikrobus)
 

Enumerations

enum  fan2_err_t {
  FAN2_OK = 0x0 , FAN2_ERR_INIT_DRV = 0xFA , FAN2_ERR_UNSUPPORTED_PIN , FAN2_ERR_REG_ADDR ,
  FAN2_ERR_NDATA , FAN2_ERR_TEMP_RANGE , FAN2_ERR_PWM_DUTY_RANGE
}
 Click error code definition. More...
 
enum  fan2_i2c_addr_t {
  FAN2_I2C_ADDR_000 = 0x50 , FAN2_I2C_ADDR_001 , FAN2_I2C_ADDR_010 , FAN2_I2C_ADDR_011 ,
  FAN2_I2C_ADDR_100 , FAN2_I2C_ADDR_101 , FAN2_I2C_ADDR_110 , FAN2_I2C_ADDR_111
}
 Click I2C address selection. More...
 

Functions

void fan2_cfg_setup (fan2_cfg_t *cfg)
 Configuration Object Initialization function.
 
fan2_err_t fan2_init (fan2_t *ctx, fan2_cfg_t *cfg)
 Click Initialization function.
 
void fan2_default_cfg (fan2_t *ctx)
 Click Default Configuration function.
 
fan2_err_t fan2_generic_write_byte (fan2_t *ctx, uint8_t reg_addr, uint8_t data_in)
 Generic Byte Write function.
 
fan2_err_t fan2_generic_read_byte (fan2_t *ctx, uint8_t reg_addr, uint8_t *data_out)
 Generic Byte Read function.
 
fan2_err_t fan2_generic_write_word (fan2_t *ctx, uint8_t reg_addr, uint16_t data_in)
 Generic Word Write function.
 
fan2_err_t fan2_generic_read_word (fan2_t *ctx, uint8_t reg_addr, uint16_t *data_out)
 Generic Word Read function.
 
fan2_err_t fan2_read_temp (fan2_t *ctx, uint8_t temp_addr, float *temp_cels)
 Temperature Read function.
 
fan2_err_t fan2_write_temp (fan2_t *ctx, uint8_t temp_addr, float temp_cels)
 Temperature Write function.
 
fan2_err_t fan2_read_tacho (fan2_t *ctx, uint8_t tacho_addr, uint16_t *tacho_rpm)
 Tachometer Read function.
 
void fan2_write_tacho_threshold (fan2_t *ctx, uint32_t tacho_rpm)
 Tachometer Threshold Write function.
 
fan2_err_t fan2_direct_speed_control (fan2_t *ctx, float speed_per)
 Direct Fan Speed Control function.
 
float fan2_read_current_speed (fan2_t *ctx)
 Current Fan Speed Read function.
 
uint8_t fan2_status (fan2_t *ctx, uint8_t flag_mask)
 Status Check function.
 
fan2_err_t fan2_write_lut (fan2_t *ctx, uint8_t lut_addr, uint8_t *lut_data, uint8_t n_data)
 Lookup Table Write function.
 
void fan2_sw_reset (fan2_t *ctx)
 Software Reset function.
 
uint8_t fan2_get_alr_pin (fan2_t *ctx)
 Alert Pin Check function.
 
uint8_t fan2_get_shd_pin (fan2_t *ctx)
 Shutdown Pin Check function.
 
uint8_t fan2_get_ff_pin (fan2_t *ctx)
 Fan-Failure Pin Check function.
 
uint8_t fan2_get_int_pin (fan2_t *ctx)
 Fault Pin Check function.
 

Detailed Description

This file contains API for Fan 2 Click driver.