Adafruit EMC2101 Library
Adafruit_EMC2101.h
Go to the documentation of this file.
1 
16 #ifndef _ADAFRUIT_EMC2101_H
17 #define _ADAFRUIT_EMC2101_H
18 
19 #include "Arduino.h"
20 #include <Adafruit_BusIO_Register.h>
21 #include <Adafruit_I2CDevice.h>
22 #include <Wire.h>
23 
24 #define EMC2101_I2CADDR_DEFAULT 0x4C
25 #define EMC2101_CHIP_ID 0x16
26 #define EMC2101_ALT_CHIP_ID 0x28
27 #define EMC2101_WHOAMI 0xFD
28 
29 #define EMC2101_INTERNAL_TEMP 0x00
30 #define EMC2101_EXTERNAL_TEMP_MSB \
31  0x01
32 #define EMC2101_EXTERNAL_TEMP_LSB \
33  0x10
34 
35 #define EMC2101_STATUS 0x02
36 #define EMC2101_REG_CONFIG 0x03
37 #define EMC2101_REG_DATA_RATE 0x04
38 #define EMC2101_TEMP_FORCE 0x0C
39 #define EMC2101_TACH_LSB 0x46
40 #define EMC2101_TACH_MSB 0x47
41 #define EMC2101_TACH_LIMIT_LSB \
42  0x48
43 #define EMC2101_TACH_LIMIT_MSB \
44  0x49
45 #define EMC2101_FAN_CONFIG 0x4A
46 #define EMC2101_FAN_SPINUP 0x4B
47 #define EMC2101_REG_FAN_SETTING \
48  0x4C
49 #define EMC2101_PWM_FREQ 0x4D
50 #define EMC2101_PWM_DIV 0x4E
51 #define EMC2101_LUT_HYSTERESIS \
52  0x4F
53 
54 #define EMC2101_LUT_START 0x50
55 
56 #define EMC2101_TEMP_FILTER \
57  0xBF
58 #define EMC2101_REG_PARTID 0xFD
59 #define EMC2101_REG_MFGID 0xFE
60 
61 #define MAX_LUT_SPEED 0x3F
62 #define MAX_LUT_TEMP 0x7F
63 
64 #define EMC2101_I2C_ADDR 0x4C
65 #define EMC2101_FAN_RPM_NUMERATOR \
66  5400000
67 #define _TEMP_LSB 0.125
68 
69 
74 typedef enum {
86 
92 public:
95 
96  bool begin(uint8_t i2c_addr = EMC2101_I2CADDR_DEFAULT, TwoWire *wire = &Wire);
97 
98  // Enable/disable & status functions:
99  bool LUTEnabled(void);
100  bool LUTEnabled(bool enable_lut);
101 
102  bool DACOutEnabled(bool enable_dac_out);
103  bool DACOutEnabled(void);
104 
105  // Accessors:
106  float getExternalTemperature(void);
107  int8_t getInternalTemperature(void);
108  uint16_t getFanRPM(void);
109 
110  uint8_t getDutyCycle(void);
111  bool setDutyCycle(uint8_t pwm_duty_cycle);
112 
113  uint16_t getFanMinRPM(void);
114  bool setFanMinRPM(uint16_t min_rpm);
115 
117  bool setDataRate(emc2101_rate_t data_rate);
118 
119  bool setLUT(uint8_t index, uint8_t temp_thresh, uint8_t fan_pwm);
120 
121  uint8_t getPWMFrequency(void);
122  bool setPWMFrequency(uint8_t pwm_freq);
123 
124  uint8_t getPWMDivisor(void);
125  bool setPWMDivisor(uint8_t pwm_divisor);
126 
127  bool configPWMClock(bool clksel, bool clkovr);
128 
129  bool setLUTHysteresis(uint8_t hysteresis);
130  uint8_t getLUTHysteresis(void);
131 
132  bool configFanSpinup(uint8_t spinup_drive, uint8_t spinup_time);
133  bool configFanSpinup(bool tach_spinup);
134 
135  bool enableForcedTemperature(bool enable_forced);
136  bool setForcedTemperature(int8_t forced_temperature);
137  int8_t getForcedTemperature(void);
138 
139  bool enableTachInput(bool tach_enable);
140  bool invertFanSpeed(bool invert_speed);
141 
142 private:
143  bool _init(void);
144 
145  Adafruit_I2CDevice *i2c_dev = NULL;
146 };
147 
148 #endif
32_HZ
Definition: Adafruit_EMC2101.h:84
bool enableTachInput(bool tach_enable)
Enable using the TACH/ALERT pin as an input to read the fan speed signal from a 4-pin fan...
Definition: Adafruit_EMC2101.cpp:115
1_16_HZ
Definition: Adafruit_EMC2101.h:75
1_HZ
Definition: Adafruit_EMC2101.h:79
4_HZ
Definition: Adafruit_EMC2101.h:81
16_HZ
Definition: Adafruit_EMC2101.h:83
Adafruit_EMC2101()
Construct a new Adafruit_EMC2101::Adafruit_EMC2101 object.
Definition: Adafruit_EMC2101.cpp:45
bool configPWMClock(bool clksel, bool clkovr)
Configure the PWM clock by selecting the clock source and overflow bit.
Definition: Adafruit_EMC2101.cpp:154
bool setPWMDivisor(uint8_t pwm_divisor)
Get the alternate PWM frequency digide value to use instead of the clock selection bit when the clock...
Definition: Adafruit_EMC2101.cpp:605
bool LUTEnabled(void)
Get the LUT enable status.
Definition: Adafruit_EMC2101.cpp:351
uint16_t getFanRPM(void)
Read the current fan speed in RPM.
Definition: Adafruit_EMC2101.cpp:470
emc2101_rate_t
Allowed values for setDataRate.
Definition: Adafruit_EMC2101.h:74
bool invertFanSpeed(bool invert_speed)
Set the cotroller to interperate fan speed settings opposite of the normal behavior.
Definition: Adafruit_EMC2101.cpp:133
bool begin(uint8_t i2c_addr=EMC2101_I2CADDR_DEFAULT, TwoWire *wire=&Wire)
Sets up the hardware and initializes I2C.
Definition: Adafruit_EMC2101.cpp:61
~Adafruit_EMC2101()
Destroy the Adafruit_EMC2101::Adafruit_EMC2101 object.
Definition: Adafruit_EMC2101.cpp:51
uint8_t getDutyCycle(void)
Get the fan speed setting used while the LUT is being updated and is unavailable or not in use...
Definition: Adafruit_EMC2101.cpp:314
int8_t getForcedTemperature(void)
Get the alternate temperature to use to look up a fan setting in the look up table.
Definition: Adafruit_EMC2101.cpp:651
bool setDutyCycle(uint8_t pwm_duty_cycle)
Set the fan speed.
Definition: Adafruit_EMC2101.cpp:331
uint8_t getPWMDivisor(void)
Get the alternate PWM frequency digide value to use instead of the clock selection bit when the clock...
Definition: Adafruit_EMC2101.cpp:593
uint8_t getPWMFrequency(void)
Read the final PWM frequency and "effective resolution" of the PWM driver. No effect when DAC output ...
Definition: Adafruit_EMC2101.cpp:564
uint8_t getLUTHysteresis(void)
Get the amount of hysteresis in Degrees celcius of hysteresis applied to temperature readings used fo...
Definition: Adafruit_EMC2101.cpp:221
float getExternalTemperature(void)
Read the external temperature diode.
Definition: Adafruit_EMC2101.cpp:431
bool setFanMinRPM(uint16_t min_rpm)
Set the minimum speed of the attached fan.
Definition: Adafruit_EMC2101.cpp:409
bool setForcedTemperature(int8_t forced_temperature)
Set the alternate temperature to use to look up a fan setting in the look up table.
Definition: Adafruit_EMC2101.cpp:637
bool setLUTHysteresis(uint8_t hysteresis)
Set the amount of hysteresis in degrees celcius of hysteresis applied to temperature readings used fo...
Definition: Adafruit_EMC2101.cpp:239
#define EMC2101_I2CADDR_DEFAULT
EMC2101 default i2c address.
Definition: Adafruit_EMC2101.h:24
bool enableForcedTemperature(bool enable_forced)
Force the LUT to use the temperature set by setForcedTemperature.
Definition: Adafruit_EMC2101.cpp:621
bool setLUT(uint8_t index, uint8_t temp_thresh, uint8_t fan_pwm)
Create a new mapping between temperature and fan speed in the Look Up Table. Requires the LUT to be e...
Definition: Adafruit_EMC2101.cpp:272
1_8_HZ
Definition: Adafruit_EMC2101.h:76
1_4_HZ
Definition: Adafruit_EMC2101.h:77
bool DACOutEnabled(void)
Get the current DAC output enable setting.
Definition: Adafruit_EMC2101.cpp:547
bool setPWMFrequency(uint8_t pwm_freq)
Set the final PWM frequency and "effective resolution" of the PWM driver. No effect when DAC output i...
Definition: Adafruit_EMC2101.cpp:581
emc2101_rate_t getDataRate(void)
Gets the current rate at which pressure and temperature measurements are taken.
Definition: Adafruit_EMC2101.cpp:498
bool setDataRate(emc2101_rate_t data_rate)
Sets the rate at which pressure and temperature measurements.
Definition: Adafruit_EMC2101.cpp:514
2_HZ
Definition: Adafruit_EMC2101.h:80
8_HZ
Definition: Adafruit_EMC2101.h:82
1_2_HZ
Definition: Adafruit_EMC2101.h:78
Class that stores state and functions for interacting with the EMC2101 Temperature monitor and fan co...
Definition: Adafruit_EMC2101.h:91
int8_t getInternalTemperature(void)
Read the internal temperature sensor.
Definition: Adafruit_EMC2101.cpp:457
uint16_t getFanMinRPM(void)
Get the mimnum RPM setting for the attached fan.
Definition: Adafruit_EMC2101.cpp:382
bool configFanSpinup(uint8_t spinup_drive, uint8_t spinup_time)
Configure the fan&#39;s spinup behavior when transitioning from off/minimal speed to a higher speed (exce...
Definition: Adafruit_EMC2101.cpp:177