/* ANY-LICENSE V1.0 ---------------- You can use these files under any license approved by the Open Source Initiative, preferrably one of the popular licenses, as long as the license you choose is compatible to the dependencies of these files. See http://www.opensource.org/licenses/ for a list of approved licenses. Author: Martin Furter Project: Tins AVR Lib Repository: http://repos.borg.ch/projects/tins_avr_lib/trunk Copyright: 2016 */ #ifndef TAL_LM75_H #define TAL_LM75_H /** \defgroup LM75 LM75 temperature sensor functions. @{ */ #include /// Base address of the LM75. #define LM75_BASE_ADDRESS 0x48 /// Temperature register number. #define LM75_REG_TEMPERATURE 0x00 /// Configuration register number. #define LM75_REG_CONFIGURATION 0x01 /// Hysteresis temperature register number. #define LM75_REG_T_HYSTERESIS 0x02 /// OS (over temp) temperature register number. #define LM75_REG_T_OS 0x03 /// If set shutdown the sensor. #define LM75_CFG_SHUTDOWN 0x01 /// Comparator mode, high temperature sets OS, low temperature clears it. #define LM75_CFG_MODE_COMPARATOR 0x00 /// Interrupt mode, trigger sets OS, read temperature clears it. #define LM75_CFG_MODE_INTERRUPT 0x02 /// OS is active low. #define LM75_CFG_OS_ACTIVE_LOW 0x00 /// OS is active high. #define LM75_CFG_OS_ACTIVE_HIGH 0x04 /// OS is set after one high temperature measurement. #define LM75_CFG_NUM_FAULT_1 0x00 /// OS is set after two high temperature measurement. #define LM75_CFG_NUM_FAULT_2 0x08 /// OS is set after four high temperature measurement. #define LM75_CFG_NUM_FAULT_4 0x10 /// OS is set after six high temperature measurement. #define LM75_CFG_NUM_FAULT_6 0x18 /** * Select the temperature register and read its value. * * @param addr LM75 address (0..7). * @param v Pointer to a variable to store the temperature. * @return true if OK, false for failure. */ uint8_t lm75_read_temp( uint8_t addr, int16_t* v ); /** * Read the value of the temperature register. * The temperature register must be already selceted by a prior call * to lm75_read_temp() and no other calls which change the selected * register. * * @param addr LM75 address (0..7). * @param v Pointer to a variable to store the temperature. * @return true if OK, false for failure. */ uint8_t lm75_read_temp_quick( uint8_t addr, int16_t* v ); /** * Selects the config register and writes the given value into it. * * @param addr LM75 address (0..7). * @param cfg Configuration value. * @return true if OK, false for failure. */ uint8_t lm75_set_config( uint8_t addr, uint8_t cfg ); /** * Selects the hysteresis temp register and writes the given value into it. * * @param addr LM75 address (0..7). * @param v Hysteresis temperature value. * @return true if OK, false for failure. */ uint8_t lm75_set_t_hyst( uint8_t addr, int16_t v ); /** * Selects the OS temperature register and writes the given value into it. * * @param addr LM75 address (0..7). * @param v OS temperature value. * @return true if OK, false for failure. */ uint8_t lm75_set_t_os( uint8_t addr, int16_t v ); /// @} #endif // TAL_LM75_H