Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
fan_click.h File Reference

mikrosdk interface More...

#include <stdint.h>
Include dependency graph for fan_click.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FAN_MODE_OPEN_LOOP   0 /* open loop, direct setting of pwm value */
 
#define FAN_MODE_CLOSED_LOOP   1 /* closed loop, rpm setting */
 
#define FAN_MODE   FAN_MODE_CLOSED_LOOP
 
#define FAN_USE_INTERRUPT   0
 
#define FAN_MAX_SPEED   5000
 
#define FAN_DRIVE_FAIL_LIMIT_PERCENT   10
 
#define FAN_MIN_SPIN_UP_VALUE_RPM   500
 
#define FAN_DEV_ADDR   0x2F
 
#define FAN_EMC2301_PRODUCTID   0x37
 
#define FAN_FREQUENCY   32768
 
#define FAN_STATUS_FNSTL   0x01
 
#define FAN_STATUS_FNSPIN   0x02
 
#define FAN_STATUS_DVFAIL   0x04
 
#define FAN_PWM_FREQ   FAN_PWM_FREQ_26000HZ /* pwm base frequency */
 
#define FAN_RANGE   FAN_RANGE_RPM_MIN_500 /* fan speed range */
 
#define FAN_EDGES   FAN_EDGES_2_POLE /* number of edges for sampling */
 
#define FAN_SPINUP_LEVEL   FAN_SPINUP_LEVEL_60PERCENT /* spin-up level */
 
#define FAN_SPINUP_TIME   FAN_SPINUP_TIME_1S /* spin-up time */
 
#define FAN_KICK   1 /* kick */
 
#define FAN_UPDATE_TIME   FAN_UPDATE_TIME_400MS /* update time */
 
#define FAN_ERR_WINDOW   FAN_ERR_WINDOW_0RPM /* fan speed error window */
 
#define FAN_DERIVATIVE   FAN_DERIVATIVE_BASIC /* pid algorithm derivative option */
 
#define FAN_GAIN_P   FAN_GAIN_4X /* pid p gain */
 
#define FAN_GAIN_I   FAN_GAIN_4X /* pid i gain */
 
#define FAN_GAIN_D   FAN_GAIN_4X /* pid d gain */
 
#define FAN_DRIVE_FAIL_COUNT   FAN_DRIVE_FAIL_COUNT_16 /* drive fail count */
 
#define FAN_RAMP_ENABLE   0 /* ramping enable */
 
#define FAN_RAMP_STEPSIZE   16 /* ramping stepsize */
 
#define FAN_ENAG_BIT   0x80
 
#define FAN_RNG_MASK   0x60
 
#define FAN_RNG_SHFT   5
 
#define FAN_EDG_MASK   0x18
 
#define FAN_EDG_SHFT   3
 
#define FAN_UDT_MASK   0x07
 
#define FAN_UDT_SHFT   0
 
#define FAN_ENRC_BIT   0x40
 
#define FAN_GHEN_BIT   0x20
 
#define FAN_DPT_MASK   0x18
 
#define FAN_DPT_SHFT   3
 
#define FAN_ERG_MASK   0x06
 
#define FAN_ERG_SHFT   1
 
#define FAN_DFC_MASK   0xC0
 
#define FAN_DFC_SHFT   6
 
#define FAN_NKCK_BIT   0x20
 
#define FAN_SPLV_MASK   0x1C
 
#define FAN_SPLV_SHFT   2
 
#define FAN_SPT_MASK   0x03
 
#define FAN_SPT_SHFT   0
 
#define FAN_GDE_MASK   0x30
 
#define FAN_GDE_SHFT   4
 
#define FAN_GIN_MASK   0x0C
 
#define FAN_GIN_SHFT   2
 
#define FAN_GPR_MASK   0x03
 
#define FAN_GPR_SHFT   0
 

Enumerations

enum  fan_alarm_state { FAN_ALARM_TRIGGERED = 0 , FAN_ALARM_CLEARED = 1 }
 
enum  fan_status {
  FAN_ST_OK = 0 , FAN_ST_ALARM_DVFAIL = 1 , FAN_ST_ALARM_FNSPIN = 2 , FAN_ST_ALARM_FNSTL = 3 ,
  FAN_ST_FAIL = 4
}
 
enum  fan_reg_address {
  FAN_REG_CONFIGURATION = 0x20 , FAN_REG_STATUS = 0x24 , FAN_REG_STALL_STATUS = 0x25 , FAN_REG_SPIN_STATUS = 0x26 ,
  FAN_REG_DRIVE_FAIL_STATUS = 0x27 , FAN_REG_INTERRUPT_ENABLE = 0x29 , FAN_REG_PWM_POLARITY = 0x2A , FAN_REG_PWM_OUTPUT_CONFIG = 0x2B ,
  FAN_REG_PWM_BASE_FREQ = 0x2D , FAN_REG_SETTING = 0x30 , FAN_REG_DIVIDE = 0x31 , FAN_REG_CONFIG1 = 0x32 ,
  FAN_REG_CONFIG2 = 0x33 , FAN_REG_GAIN = 0x35 , FAN_REG_SPINUP = 0x36 , FAN_REG_MAX_STEP = 0x37 ,
  FAN_REG_MIN_DRIVE = 0x38 , FAN_REG_VALID_TACH = 0x39 , FAN_REG_FAIL_LOW = 0x3A , FAN_REG_FAIL_HIGH = 0x3B ,
  FAN_REG_TACH_TARGET_LOW = 0x3C , FAN_REG_TACH_TARGET_HIGH = 0x3D , FAN_REG_TACH_READING_HIGH = 0x3E , FAN_REG_TACH_READING_LOW = 0x3F ,
  FAN_REG_SOFTWARE_LOCK = 0xEF , FAN_REG_PRODUCT_ID = 0xFD , FAN_REG_MANUFACTUERE_ID = 0xFE , FAN_REG_REVISION = 0xFF
}
 
enum  fan_pwm_frequency { FAN_PWM_FREQ_26000HZ = 0x00 , FAN_PWM_FREQ_19531HZ = 0x01 , FAN_PWM_FREQ_4882HZ = 0x02 , FAN_PWM_FREQ_2441HZ = 0x03 }
 
enum  fan_range { FAN_RANGE_RPM_MIN_500 = 0x00 , FAN_RANGE_RPM_MIN_1000 = 0x01 , FAN_RANGE_RPM_MIN_2000 = 0x02 , FAN_RANGE_RPM_MIN_4000 = 0x03 }
 
enum  fan_edges { FAN_EDGES_1_POLE = 0x00 , FAN_EDGES_2_POLE = 0x01 , FAN_EDGES_3_POLE = 0x02 , FAN_EDGES_4_POLE = 0x03 }
 
enum  fan_update_time {
  FAN_UPDATE_TIME_100MS = 0x00 , FAN_UPDATE_TIME_200MS = 0x01 , FAN_UPDATE_TIME_300MS = 0x02 , FAN_UPDATE_TIME_400MS = 0x03 ,
  FAN_UPDATE_TIME_500MS = 0x04 , FAN_UPDATE_TIME_800MS = 0x05 , FAN_UPDATE_TIME_1200MS = 0x06 , FAN_UPDATE_TIME_1600MS = 0x07
}
 
enum  fan_derivative_option { FAN_DERIVATIVE_NONE = 0x00 , FAN_DERIVATIVE_BASIC = 0x01 , FAN_DERIVATIVE_STEP = 0x02 , FAN_DERIVATIVE_BOTH = 0x03 }
 
enum  fan_error_window { FAN_ERR_WINDOW_0RPM = 0x00 , FAN_ERR_WINDOW_50RPM = 0x01 , FAN_ERR_WINDOW_100RPM = 0x02 , FAN_ERR_WINDOW_200RPM = 0x03 }
 
enum  fan_gain { FAN_GAIN_1X = 0x00 , FAN_GAIN_2X = 0x01 , FAN_GAIN_4X = 0x02 , FAN_GAIN_8X = 0x03 }
 
enum  fan_drive_fail_count { FAN_DRIVE_FAIL_COUNT_DISABLED = 0x00 , FAN_DRIVE_FAIL_COUNT_16 = 0x01 , FAN_DRIVE_FAIL_COUNT_32 = 0x02 , FAN_DRIVE_FAIL_COUNT_64 = 0x03 }
 
enum  fan_spin_up_level {
  FAN_SPINUP_LEVEL_30PERCENT = 0x00 , FAN_SPINUP_LEVEL_35PERCENT = 0x01 , FAN_SPINUP_LEVEL_40PERCENT = 0x02 , FAN_SPINUP_LEVEL_45PERCENT = 0x03 ,
  FAN_SPINUP_LEVEL_50PERCENT = 0x04 , FAN_SPINUP_LEVEL_55PERCENT = 0x05 , FAN_SPINUP_LEVEL_60PERCENT = 0x06 , FAN_SPINUP_LEVEL_65PERCENT = 0x07
}
 
enum  fan_spin_up_time { FAN_SPINUP_TIME_250MS = 0x00 , FAN_SPINUP_TIME_500MS = 0x01 , FAN_SPINUP_TIME_1S = 0x02 , FAN_SPINUP_TIME_2S = 0x03 }
 

Functions

uint8_t MIKROSDK_FAN_Initialise (void)
 
void MIKROSDK_FAN_pin_mapping (uint8_t alarm)
 
uint8_t MIKROSDK_FAN_alarm_triggered (void)
 
uint8_t MIKROSDK_FAN_Driver (uint8_t *speed_pwm_percent, uint16_t *speed_tach_rpm)
 

Detailed Description

mikrosdk interface

Macro Definition Documentation

◆ FAN_DERIVATIVE

#define FAN_DERIVATIVE   FAN_DERIVATIVE_BASIC /* pid algorithm derivative option */

◆ FAN_DEV_ADDR

#define FAN_DEV_ADDR   0x2F

◆ FAN_DFC_MASK

#define FAN_DFC_MASK   0xC0

◆ FAN_DFC_SHFT

#define FAN_DFC_SHFT   6

◆ FAN_DPT_MASK

#define FAN_DPT_MASK   0x18

◆ FAN_DPT_SHFT

#define FAN_DPT_SHFT   3

◆ FAN_DRIVE_FAIL_COUNT

#define FAN_DRIVE_FAIL_COUNT   FAN_DRIVE_FAIL_COUNT_16 /* drive fail count */

◆ FAN_DRIVE_FAIL_LIMIT_PERCENT

#define FAN_DRIVE_FAIL_LIMIT_PERCENT   10

◆ FAN_EDG_MASK

#define FAN_EDG_MASK   0x18

◆ FAN_EDG_SHFT

#define FAN_EDG_SHFT   3

◆ FAN_EDGES

#define FAN_EDGES   FAN_EDGES_2_POLE /* number of edges for sampling */

◆ FAN_EMC2301_PRODUCTID

#define FAN_EMC2301_PRODUCTID   0x37

◆ FAN_ENAG_BIT

#define FAN_ENAG_BIT   0x80

◆ FAN_ENRC_BIT

#define FAN_ENRC_BIT   0x40

◆ FAN_ERG_MASK

#define FAN_ERG_MASK   0x06

◆ FAN_ERG_SHFT

#define FAN_ERG_SHFT   1

◆ FAN_ERR_WINDOW

#define FAN_ERR_WINDOW   FAN_ERR_WINDOW_0RPM /* fan speed error window */

◆ FAN_FREQUENCY

#define FAN_FREQUENCY   32768

◆ FAN_GAIN_D

#define FAN_GAIN_D   FAN_GAIN_4X /* pid d gain */

◆ FAN_GAIN_I

#define FAN_GAIN_I   FAN_GAIN_4X /* pid i gain */

◆ FAN_GAIN_P

#define FAN_GAIN_P   FAN_GAIN_4X /* pid p gain */

◆ FAN_GDE_MASK

#define FAN_GDE_MASK   0x30

◆ FAN_GDE_SHFT

#define FAN_GDE_SHFT   4

◆ FAN_GHEN_BIT

#define FAN_GHEN_BIT   0x20

◆ FAN_GIN_MASK

#define FAN_GIN_MASK   0x0C

◆ FAN_GIN_SHFT

#define FAN_GIN_SHFT   2

◆ FAN_GPR_MASK

#define FAN_GPR_MASK   0x03

◆ FAN_GPR_SHFT

#define FAN_GPR_SHFT   0

◆ FAN_KICK

#define FAN_KICK   1 /* kick */

◆ FAN_MAX_SPEED

#define FAN_MAX_SPEED   5000

◆ FAN_MIN_SPIN_UP_VALUE_RPM

#define FAN_MIN_SPIN_UP_VALUE_RPM   500

◆ FAN_MODE

#define FAN_MODE   FAN_MODE_CLOSED_LOOP

◆ FAN_MODE_CLOSED_LOOP

#define FAN_MODE_CLOSED_LOOP   1 /* closed loop, rpm setting */

◆ FAN_MODE_OPEN_LOOP

#define FAN_MODE_OPEN_LOOP   0 /* open loop, direct setting of pwm value */

◆ FAN_NKCK_BIT

#define FAN_NKCK_BIT   0x20

◆ FAN_PWM_FREQ

#define FAN_PWM_FREQ   FAN_PWM_FREQ_26000HZ /* pwm base frequency */

◆ FAN_RAMP_ENABLE

#define FAN_RAMP_ENABLE   0 /* ramping enable */

◆ FAN_RAMP_STEPSIZE

#define FAN_RAMP_STEPSIZE   16 /* ramping stepsize */

◆ FAN_RANGE

#define FAN_RANGE   FAN_RANGE_RPM_MIN_500 /* fan speed range */

◆ FAN_RNG_MASK

#define FAN_RNG_MASK   0x60

◆ FAN_RNG_SHFT

#define FAN_RNG_SHFT   5

◆ FAN_SPINUP_LEVEL

#define FAN_SPINUP_LEVEL   FAN_SPINUP_LEVEL_60PERCENT /* spin-up level */

◆ FAN_SPINUP_TIME

#define FAN_SPINUP_TIME   FAN_SPINUP_TIME_1S /* spin-up time */

◆ FAN_SPLV_MASK

#define FAN_SPLV_MASK   0x1C

◆ FAN_SPLV_SHFT

#define FAN_SPLV_SHFT   2

◆ FAN_SPT_MASK

#define FAN_SPT_MASK   0x03

◆ FAN_SPT_SHFT

#define FAN_SPT_SHFT   0

◆ FAN_STATUS_DVFAIL

#define FAN_STATUS_DVFAIL   0x04

◆ FAN_STATUS_FNSPIN

#define FAN_STATUS_FNSPIN   0x02

◆ FAN_STATUS_FNSTL

#define FAN_STATUS_FNSTL   0x01

◆ FAN_UDT_MASK

#define FAN_UDT_MASK   0x07

◆ FAN_UDT_SHFT

#define FAN_UDT_SHFT   0

◆ FAN_UPDATE_TIME

#define FAN_UPDATE_TIME   FAN_UPDATE_TIME_400MS /* update time */

◆ FAN_USE_INTERRUPT

#define FAN_USE_INTERRUPT   0

Enumeration Type Documentation

◆ fan_alarm_state

Enumerator
FAN_ALARM_TRIGGERED 
FAN_ALARM_CLEARED 

◆ fan_derivative_option

Enumerator
FAN_DERIVATIVE_NONE 
FAN_DERIVATIVE_BASIC 
FAN_DERIVATIVE_STEP 
FAN_DERIVATIVE_BOTH 

◆ fan_drive_fail_count

Enumerator
FAN_DRIVE_FAIL_COUNT_DISABLED 
FAN_DRIVE_FAIL_COUNT_16 
FAN_DRIVE_FAIL_COUNT_32 
FAN_DRIVE_FAIL_COUNT_64 

◆ fan_edges

enum fan_edges
Enumerator
FAN_EDGES_1_POLE 
FAN_EDGES_2_POLE 
FAN_EDGES_3_POLE 
FAN_EDGES_4_POLE 

◆ fan_error_window

Enumerator
FAN_ERR_WINDOW_0RPM 
FAN_ERR_WINDOW_50RPM 
FAN_ERR_WINDOW_100RPM 
FAN_ERR_WINDOW_200RPM 

◆ fan_gain

enum fan_gain
Enumerator
FAN_GAIN_1X 
FAN_GAIN_2X 
FAN_GAIN_4X 
FAN_GAIN_8X 

◆ fan_pwm_frequency

Enumerator
FAN_PWM_FREQ_26000HZ 
FAN_PWM_FREQ_19531HZ 
FAN_PWM_FREQ_4882HZ 
FAN_PWM_FREQ_2441HZ 

◆ fan_range

enum fan_range
Enumerator
FAN_RANGE_RPM_MIN_500 
FAN_RANGE_RPM_MIN_1000 
FAN_RANGE_RPM_MIN_2000 
FAN_RANGE_RPM_MIN_4000 

◆ fan_reg_address

Enumerator
FAN_REG_CONFIGURATION 
FAN_REG_STATUS 
FAN_REG_STALL_STATUS 
FAN_REG_SPIN_STATUS 
FAN_REG_DRIVE_FAIL_STATUS 
FAN_REG_INTERRUPT_ENABLE 
FAN_REG_PWM_POLARITY 
FAN_REG_PWM_OUTPUT_CONFIG 
FAN_REG_PWM_BASE_FREQ 
FAN_REG_SETTING 
FAN_REG_DIVIDE 
FAN_REG_CONFIG1 
FAN_REG_CONFIG2 
FAN_REG_GAIN 
FAN_REG_SPINUP 
FAN_REG_MAX_STEP 
FAN_REG_MIN_DRIVE 
FAN_REG_VALID_TACH 
FAN_REG_FAIL_LOW 
FAN_REG_FAIL_HIGH 
FAN_REG_TACH_TARGET_LOW 
FAN_REG_TACH_TARGET_HIGH 
FAN_REG_TACH_READING_HIGH 
FAN_REG_TACH_READING_LOW 
FAN_REG_SOFTWARE_LOCK 
FAN_REG_PRODUCT_ID 
FAN_REG_MANUFACTUERE_ID 
FAN_REG_REVISION 

◆ fan_spin_up_level

Enumerator
FAN_SPINUP_LEVEL_30PERCENT 
FAN_SPINUP_LEVEL_35PERCENT 
FAN_SPINUP_LEVEL_40PERCENT 
FAN_SPINUP_LEVEL_45PERCENT 
FAN_SPINUP_LEVEL_50PERCENT 
FAN_SPINUP_LEVEL_55PERCENT 
FAN_SPINUP_LEVEL_60PERCENT 
FAN_SPINUP_LEVEL_65PERCENT 

◆ fan_spin_up_time

Enumerator
FAN_SPINUP_TIME_250MS 
FAN_SPINUP_TIME_500MS 
FAN_SPINUP_TIME_1S 
FAN_SPINUP_TIME_2S 

◆ fan_status

enum fan_status
Enumerator
FAN_ST_OK 
FAN_ST_ALARM_DVFAIL 
FAN_ST_ALARM_FNSPIN 
FAN_ST_ALARM_FNSTL 
FAN_ST_FAIL 

◆ fan_update_time

Enumerator
FAN_UPDATE_TIME_100MS 
FAN_UPDATE_TIME_200MS 
FAN_UPDATE_TIME_300MS 
FAN_UPDATE_TIME_400MS 
FAN_UPDATE_TIME_500MS 
FAN_UPDATE_TIME_800MS 
FAN_UPDATE_TIME_1200MS 
FAN_UPDATE_TIME_1600MS 

Function Documentation

◆ MIKROSDK_FAN_alarm_triggered()

uint8_t MIKROSDK_FAN_alarm_triggered ( void  )

◆ MIKROSDK_FAN_Driver()

uint8_t MIKROSDK_FAN_Driver ( uint8_t *  speed_pwm_percent,
uint16_t *  speed_tach_rpm 
)

◆ MIKROSDK_FAN_Initialise()

uint8_t MIKROSDK_FAN_Initialise ( void  )

◆ MIKROSDK_FAN_pin_mapping()

void MIKROSDK_FAN_pin_mapping ( uint8_t  alarm)