Go to the documentation of this file.
38 #include "mikrosdk_version.h"
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
63 #define FAN6_MAP_MIKROBUS( cfg, mikrobus ) \
64 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
65 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
66 cfg.io1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
67 cfg.sdn = MIKROBUS( mikrobus, MIKROBUS_RST ); \
68 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
69 cfg.io2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
70 cfg.alr = MIKROBUS( mikrobus, MIKROBUS_INT );
77 #define FAN6_RETVAL uint8_t
80 #define FAN6_INIT_ERROR 0xFF
87 #define FAN6_INTERNAL_TEMP_READ_REG 0x00
88 #define FAN6_EXTDIODE1_TEMP_READ_REG 0x02
89 #define FAN6_EXTDIODE2_TEMP_READ_REG 0x04
90 #define FAN6_EXTDIODE3_TEMP_READ_REG 0x06
91 #define FAN6_CRITICAL_TEMP_REG 0x0A
92 #define FAN6_PUSHED_TEMP1_REG 0x0C
93 #define FAN6_PUSHED_TEMP2_REG 0x0D
94 #define FAN6_TRIP_SET_VOLTAGE_REG 0x10
95 #define FAN6_EXTDIODE1_IDEALITY_REG 0x11
96 #define FAN6_EXTDIODE2_IDEALITY_REG 0x12
97 #define FAN6_EXTDIODE1_BETA_CONFIG_REG 0x14
98 #define FAN6_EXTDIODE2_BETA_CONFIG_REG 0x15
99 #define FAN6_EXTDIODE_REC_CONFIG_REG 0x17
100 #define FAN6_EXTDIODE1_TCRIT_LIMIT_REG 0x19
101 #define FAN6_EXTDIODE2_TCRIT_LIMIT_REG 0x1A
102 #define FAN6_EXTDIODE3_TCRIT_LIMIT_REG 0x1B
103 #define FAN6_INTDIODE_TCRIT_LIMIT_REG 0x1D
104 #define FAN6_TCRIT_STATUS_REG 0x1F
105 #define FAN6_CONFIGURATION_REG 0x20
106 #define FAN6_CONFIGURATION2_REG 0x21
107 #define FAN6_INTERRUPT_STATUS_REG 0x23
108 #define FAN6_HIGH_LIMIT_STATUS_REG 0x24
109 #define FAN6_LOW_LIMIT_STATUS_REG 0x25
110 #define FAN6_DIODE_FAULT_REG 0x26
111 #define FAN6_FAN_STATUS_REG 0x27
112 #define FAN6_INTERRUPT_EN_REG 0x28
113 #define FAN6_FAN_INTERRUPT_EN_REG 0x29
114 #define FAN6_PWM_CONFIG_REG 0x2A
115 #define FAN6_PWM_BASE_FREQ_REG 0x2B
116 #define FAN6_EXTDIODE1_HIGHTEMP_LIMIT_REG 0x30
117 #define FAN6_EXTDIODE2_HIGHTEMP_LIMIT_REG 0x31
118 #define FAN6_EXTDIODE3_HIGHTEMP_LIMIT_REG 0x32
119 #define FAN6_INTDIODE_HIGHTEMP_LIMIT_REG 0x34
120 #define FAN6_EXTDIODE1_LOWTEMP_LIMIT_REG 0x38
121 #define FAN6_EXTDIODE2_LOWTEMP_LIMIT_REG 0x39
122 #define FAN6_EXTDIODE3_LOWTEMP_LIMIT_REG 0x3A
123 #define FAN6_INTDIODE_LOWTEMP_LIMIT_REG 0x3C
124 #define FAN6_FAN_SETTING_REG 0x40
125 #define FAN6_PWM_DIVIDE_REG 0x41
126 #define FAN6_FAN_CONFIG1_REG 0x42
127 #define FAN6_FAN_CONFIG2_REG 0x43
128 #define FAN6_GAIN_REG 0x45
129 #define FAN6_FAN_SPINUP_CONFIG_REG 0x46
130 #define FAN6_FAN_STEP_REG 0x47
131 #define FAN6_FAN_MIN_DRIVE_REG 0x48
132 #define FAN6_FAN_VALID_TACH_COUNT_REG 0x49
133 #define FAN6_FAN_DRIVE_FAIL_BAND_REG 0x4A
134 #define FAN6_TACH_TARGET_REG 0x4C
135 #define FAN6_TACH_READING_REG 0x4E
136 #define FAN6_LUT_CONFIG_REG 0x50
137 #define FAN6_LUT_DRIVE1_REG 0x51
138 #define FAN6_LUT_TEMP1_SETTING1_REG 0x52
139 #define FAN6_LUT_TEMP2_SETTING1_REG 0x53
140 #define FAN6_LUT_TEMP3_SETTING1_REG 0x54
141 #define FAN6_LUT_INTTEMP_SETTING1_REG 0x55
142 #define FAN6_LUT_DRIVE2_REG 0x56
143 #define FAN6_LUT_TEMP1_SETTING2_REG 0x57
144 #define FAN6_LUT_TEMP2_SETTING2_REG 0x58
145 #define FAN6_LUT_TEMP3_SETTING2_REG 0x59
146 #define FAN6_LUT_INTTEMP_SETTING2_REG 0x5A
147 #define FAN6_LUT_DRIVE3_REG 0x5B
148 #define FAN6_LUT_TEMP1_SETTING3_REG 0x5C
149 #define FAN6_LUT_TEMP2_SETTING3_REG 0x5D
150 #define FAN6_LUT_TEMP3_SETTING3_REG 0x5E
151 #define FAN6_LUT_INTTEMP_SETTING3_REG 0x5F
152 #define FAN6_LUT_DRIVE4_REG 0x60
153 #define FAN6_LUT_TEMP1_SETTING4_REG 0x61
154 #define FAN6_LUT_TEMP2_SETTING4_REG 0x62
155 #define FAN6_LUT_TEMP3_SETTING4_REG 0x63
156 #define FAN6_LUT_INTTEMP_SETTING4_REG 0x64
157 #define FAN6_LUT_DRIVE5_REG 0x65
158 #define FAN6_LUT_TEMP1_SETTING5_REG 0x66
159 #define FAN6_LUT_TEMP2_SETTING5_REG 0x67
160 #define FAN6_LUT_TEMP3_SETTING5_REG 0x68
161 #define FAN6_LUT_INTTEMP_SETTING5_REG 0x69
162 #define FAN6_LUT_DRIVE6_REG 0x6A
163 #define FAN6_LUT_TEMP1_SETTING6_REG 0x6B
164 #define FAN6_LUT_TEMP2_SETTING6_REG 0x6C
165 #define FAN6_LUT_TEMP3_SETTING6_REG 0x6D
166 #define FAN6_LUT_INTTEMP_SETTING6_REG 0x6E
167 #define FAN6_LUT_DRIVE7_REG 0x6F
168 #define FAN6_LUT_TEMP1_SETTING7_REG 0x70
169 #define FAN6_LUT_TEMP2_SETTING7_REG 0x71
170 #define FAN6_LUT_TEMP3_SETTING7_REG 0x72
171 #define FAN6_LUT_INTTEMP_SETTING7_REG 0x73
172 #define FAN6_LUT_DRIVE8_REG 0x74
173 #define FAN6_LUT_TEMP1_SETTING8_REG 0x75
174 #define FAN6_LUT_TEMP2_SETTING8_REG 0x76
175 #define FAN6_LUT_TEMP3_SETTING8_REG 0x77
176 #define FAN6_LUT_INTTEMP_SETTING8_REG 0x78
177 #define FAN6_GPIO_DIR_REG 0xE1
178 #define FAN6_GPIO_OUTPUT_CONFIG_REG 0xE2
179 #define FAN6_GPIO_INPUT_REG 0xE3
180 #define FAN6_GPIO_OUTPUT_REG 0xE4
181 #define FAN6_GPIO_INTERR_EN_REG 0xE5
182 #define FAN6_GPIO_STATUS_REG 0xE6
183 #define FAN6_SW_LOCK_REG 0xEF
184 #define FAN6_PRODUCT_FEATURES_REG 0xFC
185 #define FAN6_PRODUCT_ID_REG 0xFD
186 #define FAN6_MANUFACTURER_ID_REG 0xFE
187 #define FAN6_REVISION_REG 0xFF
194 #define FAN6_AUTOBETA_DETECTION_DISABLED 0x00
195 #define FAN6_AUTOBETA_DETECTION_ENABLED 0x10
196 #define FAN6_MIN_BETA_80MILI 0x00
197 #define FAN6_MIN_BETA_111MILI 0x01
198 #define FAN6_MIN_BETA_176MILI 0x02
199 #define FAN6_MIN_BETA_290MILI 0x03
200 #define FAN6_MIN_BETA_480MILI 0x04
201 #define FAN6_MIN_BETA_900MILI 0x05
202 #define FAN6_MIN_BETA_2330MILI 0x06
203 #define FAN6_MIN_BETA_DISABLED 0x07
210 #define FAN6_EXTDIODE_REC_DISABLED 0x00
211 #define FAN6_EXTDIODE3_REC_ENABLED 0x04
212 #define FAN6_EXTDIODE2_REC_ENABLED 0x02
213 #define FAN6_EXTDIODE1_REC_ENABLED 0x01
220 #define FAN6_ALERT_PIN_UNMASKED 0x00
221 #define FAN6_ALERT_PIN_MASKED 0x80
222 #define FAN6_EXTDIODE_SYS_SHDN_PIN_NOT_LINKED 0x00
223 #define FAN6_EXTDIODE3_SYS_SHDN_PIN_LINKED 0x08
224 #define FAN6_EXTDIODE2_SYS_SHDN_PIN_LINKED 0x04
225 #define FAN6_EXTDIODE1_SYS_SHDN_PIN_LINKED 0x02
226 #define FAN6_ANTIPARALLEL_DIODE_FUNCT_DISABLED 0x00
227 #define FAN6_ANTIPARALLEL_DIODE_FUNCT_ENABLED 0x01
234 #define FAN6_DYNAMIC_AVERAGING_ENABLED 0x00
235 #define FAN6_DYNAMIC_AVERAGING_DISABLED 0x40
236 #define FAN6_SMBUS_ENABLED 0x00
237 #define FAN6_SMBUS_DISABLED 0x20
238 #define FAN6_DIGITAL_AVERAGING_ENABLED 0x00
239 #define FAN6_DIGITAL_AVERAGING_DISABLED 0x10
240 #define FAN6_CONSECUTIVE_OUTOFLIMIT_NUMBER_1 0x00
241 #define FAN6_CONSECUTIVE_OUTOFLIMIT_NUMBER_2 0x04
242 #define FAN6_CONSECUTIVE_OUTOFLIMIT_NUMBER_3 0x08
243 #define FAN6_CONSECUTIVE_OUTOFLIMIT_NUMBER_4 0x0C
244 #define FAN6_CONVERSION_RATE_1_PERSEC 0x00
245 #define FAN6_CONVERSION_RATE_2_PERSEC 0x01
246 #define FAN6_CONVERSION_RATE_4_PERSEC 0x02
247 #define FAN6_CONVERSION_RATE_CONTINUOUS 0x03
254 #define FAN6_ALL_INTERRUPTS_DISABLED 0x00
255 #define FAN6_EXTDIODE3_INTERRUPT_ENABLED 0x08
256 #define FAN6_EXTDIODE2_INTERRUPT_ENABLED 0x04
257 #define FAN6_EXTDIODE1_INTERRUPT_ENABLED 0x02
258 #define FAN6_INTDIODE_INTERRUPT_ENABLED 0x01
265 #define FAN6_ALL_FAN_INTERRUPTS_DISABLED 0x00
266 #define FAN6_FAN_SPIN_BIT_ENABLED 0x02
267 #define FAN6_FAN_STALL_BIT_ENABLED 0x01
274 #define FAN6_PWM_PIN_OPEN_DRAIN 0x00
275 #define FAN6_PWM_PIN_PUSH_PULL 0x10
276 #define FAN6_NORMAL_POLARITY 0x00
277 #define FAN6_INVERTED_POLARITY 0x01
284 #define FAN6_PWM_BASE_FREQ_26000HZ 0x00
285 #define FAN6_PWM_BASE_FREQ_19531HZ 0x01
286 #define FAN6_PWM_BASE_FREQ_4882HZ 0x02
287 #define FAN6_PWM_BASE_FREQ_2441HZ 0x03
294 #define FAN6_0_PERCENT_SPEED 0x00
295 #define FAN6_25_PERCENTS_SPEED 0x40
296 #define FAN6_50_PERCENTS_SPEED 0x80
297 #define FAN6_75_PERCENTS_SPEED 0xC0
298 #define FAN6_100_PERCENTS_SPEED 0xFF
305 #define FAN6_CONTROL_CIRCUITRY_DISABLED 0x00
306 #define FAN6_CONTROL_CIRCUITRY_ENABLED 0x80
307 #define FAN6_RANGE_MIN_500RPM 0x00
308 #define FAN6_RANGE_MIN_1000RPM 0x20
309 #define FAN6_RANGE_MIN_2000RPM 0x40
310 #define FAN6_RANGE_MIN_4000RPM 0x60
311 #define FAN6_MIN_3_EDGES 0x00
312 #define FAN6_MIN_5_EDGES 0x08
313 #define FAN6_MIN_7_EDGES 0x10
314 #define FAN6_MIN_9_EDGES 0x18
315 #define FAN6_UPDATE_TIME_100_MILISEC 0x00
316 #define FAN6_UPDATE_TIME_200_MILISEC 0x01
317 #define FAN6_UPDATE_TIME_300_MILISEC 0x02
318 #define FAN6_UPDATE_TIME_400_MILISEC 0x03
319 #define FAN6_UPDATE_TIME_500_MILISEC 0x04
320 #define FAN6_UPDATE_TIME_800_MILISEC 0x05
321 #define FAN6_UPDATE_TIME_1200_MILISEC 0x06
322 #define FAN6_UPDATE_TIME_1600_MILISEC 0x07
329 #define FAN6_RAMP_RATE_CONT_DISABLED 0x00
330 #define FAN6_RAMP_RATE_CONT_ENABLED 0x40
331 #define FAN6_GLITCH_FILTER_DISABLED 0x00
332 #define FAN6_GLITCH_FILTER_ENABLED 0x20
333 #define FAN6_NO_DERIVATIVE 0x00
334 #define FAN6_BASIC_DERIVATIVE 0x08
335 #define FAN6_STEP_DERIVATIVE 0x10
336 #define FAN6_BOTH_DERIVATIVE 0x18
337 #define FAN6_ERROR_RANGE_0RPM 0x00
338 #define FAN6_ERROR_RANGE_50RPM 0x02
339 #define FAN6_ERROR_RANGE_100RPM 0x04
340 #define FAN6_ERROR_RANGE_200RPM 0x06
347 #define FAN6_GAIN_1X 0x00
348 #define FAN6_GAIN_2X 0x15
349 #define FAN6_GAIN_4X 0x2A
350 #define FAN6_GAIN_8X 0x3F
357 #define FAN6_UPDATE_PERIODS_DISABLED 0x00
358 #define FAN6_16_UPDATE_PERIODS 0x40
359 #define FAN6_32_UPDATE_PERIODS 0x80
360 #define FAN6_64_UPDATE_PERIODS 0xC0
361 #define FAN6_100_PERCENTS_PWM_DRIVE_ENABLED 0x00
362 #define FAN6_100_PERCENTS_PWM_DRIVE_DISABLED 0x20
363 #define FAN6_SPINUP_DRIVELEVEL_30_PERCENTS 0x00
364 #define FAN6_SPINUP_DRIVELEVEL_35_PERCENTS 0x04
365 #define FAN6_SPINUP_DRIVELEVEL_40_PERCENTS 0x08
366 #define FAN6_SPINUP_DRIVELEVEL_45_PERCENTS 0x0C
367 #define FAN6_SPINUP_DRIVELEVEL_50_PERCENTS 0x10
368 #define FAN6_SPINUP_DRIVELEVEL_55_PERCENTS 0x14
369 #define FAN6_SPINUP_DRIVELEVEL_60_PERCENTS 0x18
370 #define FAN6_SPINUP_DRIVELEVEL_65_PERCENTS 0x1C
371 #define FAN6_SPINUP_TIME_250_MILISEC 0x00
372 #define FAN6_SPINUP_TIME_500_MILISEC 0x01
373 #define FAN6_SPINUP_TIME_1_SEC 0x02
374 #define FAN6_SPINUP_TIME_2_SEC 0x03
381 #define FAN6_PUSH_TEMP_NOT_LOADED 0x00
382 #define FAN6_PUSH_TEMP1_LOADED 0x80
383 #define FAN6_PUSH_TEMP2_LOADED 0x40
384 #define FAN6_LUT_ENABLED 0x00
385 #define FAN6_LUT_LOCKED 0x20
386 #define FAN6_RPM_TACH_ENABLED 0x00
387 #define FAN6_PWM_DUTY_ENABLED 0x10
394 #define FAN6_GPIO_DIR_INPUT 0x00
395 #define FAN6_GPIO2_DIR_OUTPUT 0x02
396 #define FAN6_GPIO1_DIR_OUTPUT 0x01
403 #define FAN6_GPIO_AS_OPEN_DRAIN 0x00
404 #define FAN6_GPIO2_AS_PUSH_PULL 0x02
405 #define FAN6_GPIO1_AS_PUSH_PULL 0x01
412 #define FAN6_GPIO_INTERR_DISABLED 0x00
413 #define FAN6_GPIO2_INTERR_ENABLED 0x02
414 #define FAN6_GPIO1_INTERR_ENABLED 0x01
421 #define FAN6_SW_NOT_LOCKED 0x00
422 #define FAN6_SW_LOCKED 0x01
void fan6_read_eeprom(fan6_t *ctx, uint8_t *data_out)
EEPROM read function.
pin_name_t io1
Definition: fan6.h:475
void fan6_set_gpio_1(fan6_t *ctx, const uint8_t state)
GPIO 1 Set function.
uint8_t adc_mode
Definition: fan6.h:457
void fan6_set_pwm_lut_mode(fan6_t *ctx, const uint8_t tach_count)
Set PWM With LUT Mode function.
digital_out_t en
Definition: fan6.h:440
float fan6_get_temperature(fan6_t *ctx, const uint8_t temp_address)
Temperature Get function.
uint32_t fan6_read_tachometer(fan6_t *ctx)
Tachometer Read function.
uint32_t i2c_speed
Definition: fan6.h:483
void fan6_generic_read(fan6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
pin_name_t scl
Definition: fan6.h:470
void fan6_cfg_setup(fan6_cfg_t *cfg)
Config Object Initialization function.
Click ctx object definition.
Definition: fan6.h:436
uint8_t config_byte2
Definition: fan6.h:459
uint16_t fan6_read_reg(fan6_t *ctx, const uint8_t register_address)
Generic read function.
i2c_master_t i2c
Definition: fan6.h:450
digital_in_t alr
Definition: fan6.h:446
digital_out_t io1
Definition: fan6.h:439
uint8_t slave_address
Definition: fan6.h:454
digital_in_t sdn
Definition: fan6.h:444
void fan6_set_pwm_mode(fan6_t *ctx, const uint8_t pwm_duty)
PWM mode set function.
void fan6_generic_write(fan6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
pin_name_t sda
Definition: fan6.h:471
pin_name_t sdn
Definition: fan6.h:476
uint8_t config_byte1
Definition: fan6.h:458
Click configuration structure definition.
Definition: fan6.h:467
pin_name_t en
Definition: fan6.h:477
void fan6_push_temperature(fan6_t *ctx, const uint8_t temp_address, const uint8_t temp_selection)
Temperature Push function.
uint8_t fan6_receive_byte(fan6_t *ctx, const uint8_t register_address)
Byte receive function.
FAN6_RETVAL fan6_init(fan6_t *ctx, fan6_cfg_t *cfg)
Initialization function.
#define FAN6_RETVAL
Definition: fan6.h:77
void fan6_set_fan_speed_con_mode(fan6_t *ctx, const uint8_t minimum_drive, const uint8_t tach_count, const uint16_t tach_target)
Fan Speed Control Mode Set function.
void fan6_enable_device(fan6_t *ctx, const uint8_t state)
Device Enable function.
pin_name_t alr
Definition: fan6.h:479
uint8_t i2c_address
Definition: fan6.h:484
digital_in_t io2
Definition: fan6.h:445
uint8_t check_ptr
Definition: fan6.h:456
void fan6_default_cfg(fan6_t *ctx)
Click Default Configuration function.
pin_name_t io2
Definition: fan6.h:478
void fan6_set_fsc_lut_mode(fan6_t *ctx, const uint8_t minimum_drive, const uint8_t tach_count)
Set FSC With LUT Mode function.
uint8_t fan6_indicate_critical_thermal_shutdown(fan6_t *ctx)
Interrupt Pin Get function.
void fan6_write_reg(fan6_t *ctx, const uint8_t register_address, const uint16_t transfer_data)
Generic write function.
uint8_t fan6_get_gpio_2(fan6_t *ctx)
GPIO 2 Get function.