fan 2.0.0.0
fan.h File Reference

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

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

Go to the source code of this file.

Data Structures

struct  fan_setup_t
 Fan setup definition. More...
 
struct  fan_setup_cfg_t
 Fan setup configuration. More...
 
struct  fan_t
 Click context object definition. More...
 
struct  fan_cfg_t
 Click configuration structure definition. More...
 

Macros

#define FAN_MAP_MIKROBUS(cfg, mikrobus)
 
#define FAN_CONFIGURATION   0x20
 
#define FAN_STATUS   0x24
 
#define FAN_STALL_STATUS   0x25
 
#define FAN_SPIN_STATUS   0x26
 
#define FAN_DRIVE_FAIL_STATUS   0x27
 
#define FAN_INTERRUPT_ENABLE   0x29
 
#define FAN_PWM_POLARITY   0x2A
 
#define FAN_PWM_OUTPUT_CONFIG   0x2B
 
#define FAN_PWM_BASE_FREQ   0x2D
 
#define FAN_SETTING   0x30
 
#define FAN_DIVIDE   0x31
 
#define FAN_CONFIG1   0x32
 
#define FAN_CONFIG2   0x33
 
#define FAN_GAIN   0x35
 
#define FAN_SPINUP   0x36
 
#define FAN_MAX_STEP   0x37
 
#define FAN_MIN_DRIVE   0x38
 
#define FAN_VALID_TACH   0x39
 
#define FAN_FAIL_LOW   0x3A
 
#define FAN_FAIL_HIGH   0x3B
 
#define FAN_TACH_TARGET_LOW   0x3C
 
#define FAN_TACH_TARGET_HIGH   0x3D
 
#define FAN_TACH_READING_HIGH   0x3E
 
#define FAN_TACH_READING_LOW   0x3F
 
#define FAN_SOFTWARE_LOCK   0xEF
 
#define FAN_PRODUCT_ID   0xFD
 
#define FAN_MANUFACTUERE_ID   0xFE
 
#define FAN_REVISION   0xFF
 
#define FAN_RPM_MIN_500   0x00
 
#define FAN_RPM_MIN_1000   0x01
 
#define FAN_RPM_MIN_2000   0x02
 
#define FAN_RPM_MIN_4000   0x03
 
#define FAN_EDGE_1_POLE   0x00
 
#define FAN_EDGE_2_POLE   0x01
 
#define FAN_EDGE_3_POLE   0x02
 
#define FAN_EDGE_4_POLE   0x03
 
#define FAN_UPDATE_100MS   0x00
 
#define FAN_UPDATE_200MS   0x01
 
#define FAN_UPDATE_300MS   0x02
 
#define FAN_UPDATE_400MS   0x03
 
#define FAN_UPDATE_500MS   0x04
 
#define FAN_UPDATE_800MS   0x05
 
#define FAN_UPDATE_1200MS   0x06
 
#define FAN_UPDATE_1600MS   0x07
 
#define FAN_DERIVATIVE_NONE   0x00
 
#define FAN_DERIVATIVE_BASIC   0x01
 
#define FAN_DERIVATIVE_STEP   0x02
 
#define FAN_DERIVATIVE_BOTH   0x03
 
#define FAN_RPM_0   0x00
 
#define FAN_RPM_50   0x01
 
#define FAN_RPM_100   0x02
 
#define FAN_RPM_200   0x03
 
#define FAN_GAIN_1X   0x00
 
#define FAN_GAIN_2X   0x01
 
#define FAN_GAIN_4X   0x02
 
#define FAN_GAIN_8X   0x03
 
#define FAN_DRIVE_CNT_DISABLED   0x0
 
#define FAN_DRIVE_CNT_16   0x0
 
#define FAN_DRIVE_CNT_32   0x0
 
#define FAN_DRIVE_CNT_64   0x0
 
#define FAN_SPINUP_30PERCENT   0x00
 
#define FAN_SPINUP_35PERCENT   0x01
 
#define FAN_SPINUP_40PERCENT   0x02
 
#define FAN_SPINUP_45PERCENT   0x03
 
#define FAN_SPINUP_50PERCENT   0x04
 
#define FAN_SPINUP_55PERCENT   0x05
 
#define FAN_SPINUP_60PERCENT   0x06
 
#define FAN_SPINUP_65PERCENT   0x07
 
#define FAN_SPINUP_250MS   0x00
 
#define FAN_SPINUP_500MS   0x00
 
#define FAN_SPINUP_1S   0x00
 
#define FAN_SPINUP_2S   0x00
 
#define EN_ALGO   ( 1 << 7 )
 
#define RANGE   ( 1 << 5 ) | ( 1 << 6 )
 
#define RANGE_BIT   5
 
#define EDGES   ( 1 << 3 ) | ( 1 << 4 )
 
#define EDGES_BIT   3
 
#define UPDATE   ( 1 << 0 ) | ( 1 << 1 ) | ( 1 << 2 )
 
#define UPDATE_BIT   0
 
#define EN_RAMP   ( 1 << 6 )
 
#define GLITCH_EN   ( 1 << 5 )
 
#define DER_OPT   ( 1 << 3 ) | ( 1 << 4 )
 
#define DER_OPT_BIT   3
 
#define ERR_RNG   ( 1 << 2 ) | ( 1 << 1 )
 
#define ERR_RNG_BIT   1
 
#define GAIND   ( 1 << 5 ) | ( 1 << 4 )
 
#define GAIND_BIT   4
 
#define GAINI   ( 1 << 3 ) | ( 1 << 2 )
 
#define GAINI_BIT   2
 
#define GAINP   ( 1 << 1 ) | ( 1 << 0 )
 
#define GAINP_BIT   0
 
#define NOKICK   ( 1 << 5 )
 
#define DRIVE_FAIL_CNT   ( 1 << 7 ) | ( 1 << 6 )
 
#define DRIVE_FAIL_CNT_BIT   6
 
#define SPIN_LVL   ( 1 << 4 ) | ( 1 << 3 ) | ( 1 << 2 )
 
#define SPIN_LVL_BIT   2
 
#define SPINUP_TIME   ( 1 << 1 ) | ( 1 << 0 )
 
#define SPINUP_TIME_BIT   0
 
#define TACH_CONSTANT   3932160
 
#define SEC_MIN   60
 
#define FAN_DEV_ADDR   0x2F
 

Functions

void fan_cfg_setup (fan_cfg_t *cfg)
 Config Object Initialization function.
 
err_t fan_default_cfg (fan_t *ctx)
 Click Default Configuration function.
 
err_t fan_init (fan_t *ctx, fan_cfg_t *cfg)
 Initialization function.
 
err_t fan_generic_write (fan_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Generic write function.
 
err_t fan_generic_read (fan_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Generic read function.
 
err_t fan_write_byte (fan_t *ctx, uint8_t reg, uint8_t data_in)
 Write byte function.
 
err_t fan_read_byte (fan_t *ctx, uint8_t reg, uint8_t *data_out)
 Read byte function.
 
err_t fan_lock_registers (fan_t *ctx, uint8_t lock)
 Fan lock registers function.
 
err_t fan_device_info (fan_t *ctx, uint8_t *info)
 Get device info function.
 
err_t fan_set_valid_tach (fan_t *ctx, uint16_t tach)
 Set valid tach function.
 
err_t fan_get_valid_tach (fan_t *ctx, uint16_t *data_out)
 Get valid tach function.
 
err_t fan_get_driveband_fail (fan_t *ctx, uint16_t *data_out)
 Get drive band fail function.
 
err_t fan_set_target_tach (fan_t *ctx, uint16_t tach)
 Set target tach function.
 
err_t fan_get_tach (fan_t *ctx, uint16_t *data_out)
 Get tach function.
 
err_t fan_enable_fsc (fan_t *ctx, uint8_t fsc)
 Enable fan control algorithm function.
 
err_t fan_set_range (fan_t *ctx, uint8_t range)
 Set number of edges that needs to be detected function.
 
err_t fan_set_edges (fan_t *ctx, uint8_t edges)
 Set number of edges on fan function.
 
err_t fan_set_update (fan_t *ctx, uint8_t update)
 Update time function.
 
err_t fan_enable_ramp (fan_t *ctx, uint8_t ramp_control)
 Ramp up mode function.
 
err_t fan_enable_glitch (fan_t *ctx, uint8_t glitch)
 Glitch enable function.
 
err_t fan_set_derivative (fan_t *ctx, uint8_t derivative)
 Set derivative function.
 
err_t fan_set_error_range (fan_t *ctx, uint8_t error)
 Set error range function.
 
err_t fan_set_gaind (fan_t *ctx, uint8_t gain)
 Set gain D function.
 
err_t fan_set_drivefail (fan_t *ctx, uint8_t count)
 Set drive fail counter function.
 
err_t fan_enable_no_kick (fan_t *ctx, uint8_t no_kick)
 No kick enable function.
 
err_t fan_set_spin_level (fan_t *ctx, uint8_t spin)
 Set spin level function.
 
err_t fan_set_spin_time (fan_t *ctx, uint8_t time)
 Set spin time function.
 
err_t fan_set_max_step (fan_t *ctx, uint8_t step)
 Set maximum step function.
 
err_t fan_set_min_drive (fan_t *ctx, double min_drive)
 Set minimum drive function.
 
void fan_update_multiplier (fan_t *ctx)
 Update multiplier function.
 
void fan_set_clock (fan_t *ctx, double freq)
 Set external clock speed function.
 
err_t fan_device_cfg (fan_t *ctx, uint8_t cfg)
 Fan configuration function.
 
err_t fan_get_status (fan_t *ctx, uint8_t *data_out)
 Get fan status function.
 
err_t fan_get_stall_status (fan_t *ctx, uint8_t *data_out)
 Get fan stall status function.
 
err_t fan_get_spin_status (fan_t *ctx, uint8_t *data_out)
 Get spin status function.
 
err_t fan_get_drive_fail (fan_t *ctx, uint8_t *data_out)
 Get fan drive fail status function.
 
err_t fan_interrupts (fan_t *ctx, uint8_t enable)
 Enable / disable external interrupts function.
 
err_t fan_pwm_base (fan_t *ctx, uint8_t freq)
 Set PWM base frequency function.
 
err_t fan_setting (fan_t *ctx, double percentage)
 Fan setting function.
 
uint8_t fan_read_int_pin (fan_t *ctx)
 Read INT pin function.
 

Detailed Description

This file contains API for Fan Click driver.