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 #define MAX_LUT_SPEED 0x3F
70 #define MAX_LUT_TEMP 0x7F
71 
72 
77 typedef enum {
89 
95 public:
98 
99  bool begin(uint8_t i2c_addr = EMC2101_I2CADDR_DEFAULT, TwoWire *wire = &Wire);
100 
101  // Enable/disable & status functions:
102  bool LUTEnabled(void);
103  bool LUTEnabled(bool enable_lut);
104 
105  bool DACOutEnabled(bool enable_dac_out);
106  bool DACOutEnabled(void);
107 
108  // Accessors:
109  float getExternalTemperature(void);
110  int8_t getInternalTemperature(void);
111  uint16_t getFanRPM(void);
112 
113  uint8_t getDutyCycle(void);
114  bool setDutyCycle(uint8_t pwm_duty_cycle);
115 
116  uint16_t getFanMinRPM(void);
117  bool setFanMinRPM(uint16_t min_rpm);
118 
120  bool setDataRate(emc2101_rate_t data_rate);
121 
122  bool setLUT(uint8_t index, uint8_t temp_thresh, uint8_t fan_pwm);
123 
124  uint8_t getPWMFrequency(void);
125  bool setPWMFrequency(uint8_t pwm_freq);
126 
127  uint8_t getPWMDivisor(void);
128  bool setPWMDivisor(uint8_t pwm_divisor);
129 
130  bool configPWMClock(bool clksel, bool clkovr);
131 
132  bool setLUTHysteresis(uint8_t hysteresis);
133  uint8_t getLUTHysteresis(void);
134 
135  bool configFanSpinup(uint8_t spinup_drive, uint8_t spinup_time);
136  bool configFanSpinup(bool tach_spinup);
137 
138  bool enableForcedTemperature(bool enable_forced);
139  bool setForcedTemperature(int8_t forced_temperature);
140  int8_t getForcedTemperature(void);
141 
142  bool enableTachInput(bool tach_enable);
143  bool invertFanSpeed(bool invert_speed);
144 
145 private:
146  bool _init(void);
147 
148  Adafruit_I2CDevice *i2c_dev = NULL;
149 };
150 
151 #endif
32_HZ
Definition: Adafruit_EMC2101.h:87
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:78
1_HZ
Definition: Adafruit_EMC2101.h:82
4_HZ
Definition: Adafruit_EMC2101.h:84
16_HZ
Definition: Adafruit_EMC2101.h:86
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:77
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:79
1_4_HZ
Definition: Adafruit_EMC2101.h:80
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:83
8_HZ
Definition: Adafruit_EMC2101.h:85
1_2_HZ
Definition: Adafruit_EMC2101.h:81
Class that stores state and functions for interacting with the EMC2101 Temperature monitor and fan co...
Definition: Adafruit_EMC2101.h:94
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