fan 2.0.0.0
Public Functions

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

Function Documentation

◆ fan_cfg_setup()

void fan_cfg_setup ( fan_cfg_t * cfg)

Config Object Initialization function.

Parameters
[out]cfgClick configuration structure. See fan_cfg_t object definition.

@description This function initializes click configuration structure to initial state.

Note
All used pins will be set to unconnected state.

◆ fan_default_cfg()

err_t fan_default_cfg ( fan_t * ctx)

Click Default Configuration function.

Parameters
[in]ctxClick object. See fan_t object definition.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description This function executes a default configuration for the FAN click.

◆ fan_device_cfg()

err_t fan_device_cfg ( fan_t * ctx,
uint8_t cfg )

Fan configuration function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]cfgTarget configuration value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Configuration Register controls the basic functionality of the EMC2301.

◆ fan_device_info()

err_t fan_device_info ( fan_t * ctx,
uint8_t * info )

Get device info function.

Parameters
[in]ctxClick object. See fan_t object definition.
[out]infoOutput info.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description 1 - Product ID, 2 - Manufacturer ID, 3 - Revision number.

◆ fan_enable_fsc()

err_t fan_enable_fsc ( fan_t * ctx,
uint8_t fsc )

Enable fan control algorithm function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]fscTrue enable fan control, false manual mode.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description This function enable Fan Control Algorithm.

◆ fan_enable_glitch()

err_t fan_enable_glitch ( fan_t * ctx,
uint8_t glitch )

Glitch enable function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]glitchTrue enable glitch filter.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description Disables the low pass glitch filter that removes high frequency noise injected on the TACHx pin.

◆ fan_enable_no_kick()

err_t fan_enable_no_kick ( fan_t * ctx,
uint8_t no_kick )

No kick enable function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]no_kickTrue enable no kick functionality.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description Turns ON no kick functionality.

◆ fan_enable_ramp()

err_t fan_enable_ramp ( fan_t * ctx,
uint8_t ramp_control )

Ramp up mode function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]tamp_controlTrue enable ramp rate control.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description Enables ramp rate control when the fan driver is operated in the Direct Setting Mode.

◆ fan_generic_read()

err_t fan_generic_read ( fan_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

Generic read function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]regRegister address.
[out]data_outOutput data buffer.
[in]lenNumber of bytes to be read.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description This function reads the desired number of data bytes starting from the selected register.

◆ fan_generic_write()

err_t fan_generic_write ( fan_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

Generic write function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]regRegister address.
[in]data_inData to be written.
[in]lenNumber of bytes to be written.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description This function writes the desired number of data bytes starting from the selected register.

◆ fan_get_drive_fail()

err_t fan_get_drive_fail ( fan_t * ctx,
uint8_t * data_out )

Get fan drive fail status function.

Parameters
[in]ctxClick object. See fan_t object definition.
[out]data_outOutput status value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Fan Drive Fail Status register indicates that the fan driver cannot drive to the programmed speed even at 100% duty cycle.

◆ fan_get_driveband_fail()

err_t fan_get_driveband_fail ( fan_t * ctx,
uint16_t * data_out )

Get drive band fail function.

Parameters
[in]ctxClick object. See fan_t object definition.
[out]data_outOutput read value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Fan Drive Fail Band Registers store the number of tach counts used by the Fan Drive Fail detection circuitry. This circuitry is activated when the fan drive setting high byte is at FFh. When it is enabled, the actual measured fan speed is compared against the target fan speed. These registers are only used when the FSC is active.

◆ fan_get_spin_status()

err_t fan_get_spin_status ( fan_t * ctx,
uint8_t * data_out )

Get spin status function.

Parameters
[in]ctxClick object. See fan_t object definition.
[out]data_outOutput status value.
  • FAN_SPIN has failed = 1
  • FAN_SPIN ok = 0
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Fan Spin Status register indicates that the fan driver has failed to spin-up.

◆ fan_get_stall_status()

err_t fan_get_stall_status ( fan_t * ctx,
uint8_t * data_out )

Get fan stall status function.

Parameters
[in]ctxClick object. See fan_t object definition.
[out]data_outOutput status value.
  • FAN_STALL = 1
  • FAN_SPIN = 2
  • FAN_DRIVE_FAIL = 4
  • FAN_WATCH = 128
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The TACH Target Registers hold the target tachometer value that is maintained by the RPM-based Fan Speed Control Algorithm.

◆ fan_get_status()

err_t fan_get_status ( fan_t * ctx,
uint8_t * data_out )

Get fan status function.

Parameters
[in]ctxClick object. See fan_t object definition.
[out]data_outOutput status value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Fan Status register indicates that the fan driver has stalled or failed or that the Watchdog Timer has expired.

◆ fan_get_tach()

err_t fan_get_tach ( fan_t * ctx,
uint16_t * data_out )

Get tach function.

Parameters
[in]ctxClick object. See fan_t object definition.
[out]data_outOutput tach value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The TACH Count register stores the current TACH Reading Register value to show the current reading of rotation per minute.

◆ fan_get_valid_tach()

err_t fan_get_valid_tach ( fan_t * ctx,
uint16_t * data_out )

Get valid tach function.

Parameters
[in]ctxClick object. See fan_t object definition.
[out]data_outOutput tach value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Valid TACH Count register stores the maximum TACH Reading Register value to indicate that the fan is spinning properly. The value is referenced at the end of the Spin Up Routine to determine if the fan has started operating and decide if the device needs to retry.

◆ fan_init()

err_t fan_init ( fan_t * ctx,
fan_cfg_t * cfg )

Initialization function.

Parameters
[out]ctxClick object. See fan_t object definition.
[in]cfgClick configuration structure. See fan_cfg_t object definition.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description This function initializes all necessary pins and peripherals used for this click board.

◆ fan_interrupts()

err_t fan_interrupts ( fan_t * ctx,
uint8_t enable )

Enable / disable external interrupts function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]enableTrue enable external interrupts.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Fan Interrupt Enable controls the masking for the Fan channel. When a channel is enabled, it will cause the ALERT# pin to be asserted when an error condition is detected.

◆ fan_lock_registers()

err_t fan_lock_registers ( fan_t * ctx,
uint8_t lock )

Fan lock registers function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]lockLock command.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Lock Column describes the locking mechanism, if any, used for individual registers. All SWL registers are Software Locked and therefore made read-only when the LOCK bit is set..

◆ fan_pwm_base()

err_t fan_pwm_base ( fan_t * ctx,
uint8_t freq )

Set PWM base frequency function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]freqTarget frequency value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The PWM Base Frequency register determines the base frequency that is used with the PWM Divide register to determine the final PWM frequency.

◆ fan_read_byte()

err_t fan_read_byte ( fan_t * ctx,
uint8_t reg,
uint8_t * data_out )

Read byte function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]regRegister address.
[out]data_outOutput data.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description This function reads one byte of data from the selected register.

◆ fan_read_int_pin()

uint8_t fan_read_int_pin ( fan_t * ctx)

Read INT pin function.

Parameters
[in]ctxClick object. See fan_t object definition.
Returns
True or false.

@description Reads the current digital level of INT pin.

◆ fan_set_clock()

void fan_set_clock ( fan_t * ctx,
double freq )

Set external clock speed function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]freqTarget frequency.

@description Specifies external clock speed if different from standard.

◆ fan_set_derivative()

err_t fan_set_derivative ( fan_t * ctx,
uint8_t derivative )

Set derivative function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]derivativeBasic derivative / Step Derivative / Both.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description Control some of the advanced options that affect the derivative portion of the RPM-based Fan Speed Control Algorithm.

◆ fan_set_drivefail()

err_t fan_set_drivefail ( fan_t * ctx,
uint8_t count )

Set drive fail counter function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]countDisabled / 16 / 32 / 64.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description Determines how many update cycles are used for the Drive Fail detection function.

◆ fan_set_edges()

err_t fan_set_edges ( fan_t * ctx,
uint8_t edges )

Set number of edges on fan function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]edgesTarget value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description Determines the minimum number of edges that must be detected on the TACHx signal to determine a single rotation. A typical fan measured 5 edges (for a 2-pole fan). For more accurate tachometer measurement, the minimum number of edges measured may be increased.

◆ fan_set_error_range()

err_t fan_set_error_range ( fan_t * ctx,
uint8_t error )

Set error range function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]errorTarget error value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description Control some of the advanced options that affect the error window. When the measured fan speed is within the programmed error window around the target speed, then the fan drive setting is not updated.

◆ fan_set_gaind()

err_t fan_set_gaind ( fan_t * ctx,
uint8_t gain )

Set gain D function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]gainTarget gain value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description Control some of the advanced options that affect the derivative portion of the RPM-based Fan Speed Control Algorithm. The Gain register stores the gain terms used by the proportional and integral portions of the RPM-based Fan Speed Control Algorithm. These gain terms are used as the KD, KI, and KP gain terms in a classic PID control solution.

◆ fan_set_max_step()

err_t fan_set_max_step ( fan_t * ctx,
uint8_t step )

Set maximum step function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]stepMaximum step value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Fan Max Step register, along with the Update Time, controls the ramp rate of the fan driver response calculated by the RPM-based Fan Speed Control Algorithm. The value of the register represents the maximum step size the fan driver will take between update times.

◆ fan_set_min_drive()

err_t fan_set_min_drive ( fan_t * ctx,
double min_drive )

Set minimum drive function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]min_driveMinimum drive value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Fan Minimum Drive register stores the minimum drive setting for the RPM-based Fan Speed Control Algorithm. The RPM-based Fan Speed Control Algorithm will not drive the fan at a level lower than the minimum drive unless the target Fan Speed is set at FFh.

◆ fan_set_range()

err_t fan_set_range ( fan_t * ctx,
uint8_t range )

Set number of edges that needs to be detected function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]rangeTarget value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description Adjusts the range of reported and programmed tachometer reading values. The RANGE bits determine the weighting of all TACH values.

◆ fan_set_spin_level()

err_t fan_set_spin_level ( fan_t * ctx,
uint8_t spin )

Set spin level function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]spinTarget spin level.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description Determines if the Spin Up Routine will drive the fan to 100% duty cycle for 1/4 of the programmed spin up time before driving it at the programmed level.

◆ fan_set_spin_time()

err_t fan_set_spin_time ( fan_t * ctx,
uint8_t time )

Set spin time function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]timeTarget time value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Fan Spin Up Configuration register controls the settings of Spin Up Routine.

◆ fan_set_target_tach()

err_t fan_set_target_tach ( fan_t * ctx,
uint16_t tach )

Set target tach function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]tachTarget tach value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The TACH Target Registers hold the target tachometer value that is maintained by the RPM-based Fan Speed Control Algorithm.

◆ fan_set_update()

err_t fan_set_update ( fan_t * ctx,
uint8_t update )

Update time function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]updateTime to be updated.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description determines the base time between fan driver updates. The Update Time, along with the Fan Step Register, is used to control the ramp rate of the drive response to provide a cleaner transition of the actual fan operation as the desired fan speed changes.

◆ fan_set_valid_tach()

err_t fan_set_valid_tach ( fan_t * ctx,
uint16_t tach )

Set valid tach function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]tachTach value.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Valid TACH Count register stores the maximum TACH Reading Register value to indicate that the fan is spinning properly. The value is referenced at the end of the Spin Up Routine to determine if the fan has started operating and decide if the device needs to retry.

◆ fan_setting()

err_t fan_setting ( fan_t * ctx,
double percentage )

Fan setting function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]percentagePercentage of duty.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description The Fan Setting register always displays the current setting of the fan driver. Reading from the register will report the current fan speed setting of the fan driver regardless of the operating mode. Therefore it is possible that reading from this register will not report data that was previously written into this register.

◆ fan_update_multiplier()

void fan_update_multiplier ( fan_t * ctx)

Update multiplier function.

Parameters
[in]ctxClick object. See fan_t object definition.

@description Performs update of multiplier.

◆ fan_write_byte()

err_t fan_write_byte ( fan_t * ctx,
uint8_t reg,
uint8_t data_in )

Write byte function.

Parameters
[in]ctxClick object. See fan_t object definition.
[in]regRegister address.
[in]data_inData byte to be written.
Returns
See #err_t definition type of data. 0 - Ok, (-1) - Error.

@description This function writes one byte of data to the selected register.