/* * Copyright (C) 2013 Zakaria Kasmi * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. */ /** * @defgroup drivers_lm75a LM75A * @ingroup drivers_sensors * @brief Driver for the LM75A digital temperature sensor and thermal watchdog * * The connection between the MCU and the LM75A is based on the i2c-interface. * * @{ * * @file * @internal * @brief Definitions of the LM75A temperature sensor driver. * * The connection between the LM75A and the MCU is based on the I2C-interface. * * @author Zakaria Kasmi */ #ifndef LM75A_H_ #define LM75A_H_ #include #include #include "i2c.h" #ifdef __cplusplus extern "C" { #endif /** * @name LM75A register addresses * @{ */ #define LM75A_ADDR 0x48 #define LM75A_TEMPERATURE_REG 0x0 #define LM75A_CONFIG_REG 0x1 #define LM75A_THYST_REG 0x2 #define LM75A_OVER_TEMP_REG 0x3 /** @} */ /** * @brief Define the used I2C Interface */ //#define LM75A_I2C_INTERFACE I2C0 // P0.27 SDA0, P0.28 SCL0 #define LM75A_I2C_INTERFACE I2C1_0 // P0.0 SDA1, P0.1 SCL1 //#define LM75A_I2C_INTERFACE I2C1_1 // P0.19 SDA1, P0.20 SCL1 //#define LM75A_I2C_INTERFACE I2C2 // P0.10 SDA2, P0.11 SCL2 /** * @brief LM75A operation modes */ enum OPERATION_MODES { LM75A_NORMAL_OPERATION_MODE, LM75A_SHUTDOWN_MODE, LM75A_COMPARATOR_MODE, LM75A_INTERRUPT_MODE }; /** * @name Common definitions for LMA75A * @{ */ #define LM75A_BIT0 0x0 #define LM75A_BIT1 0x1 #define LM75A_BIT2 0x2 #define LM75A_BIT3 0x3 #define LM75A_BIT4 0x4 #define LM75A_BIT5 0x5 #define LM75A_BIT6 0x6 #define LM75A_BIT7 0x7 #define LM75A_BIT8 0x8 #define LM75A_BIT9 0x9 #define LM75A_BIT10 0xA #define LM75A_BIT15 0xF #define LM75A_MOST_SIG_BYTE_MASK 0xFF00 #define LM75A_LEAST_SIG_BYTE_MASK 0x00FF #define LM75A_DATA_BITS_MASK 0x07FF #define LM75A_SIGN_BIT_MASK (1< BIT0, * Pin1 --> BIT1, Pin2 --> BIT2 = 2^2 = 4 * @param[in] flags define if the interrupt is generated on rising * or falling edge (#GPIOINT_RISING_EDGE, * #GPIOINT_FALLING_EDGE). * @param[in] handler pointer to an interrupt handler. * * @return true if the the external interrupt handler is successfully * registered, otherwise false. */ bool lm75A_ext_irq_handler_register(int32_t port, uint32_t pin_bit_mask, int32_t flags, void *handler); /** * @brief Initialize the LM75A temperature sensor. * The baud rate and the handler for the external interrupt can be * initialized. The external interrupt handler is optional, if no * handler is available, the NULL-value can be entered. * The hysteresis and the over-temperature are displayed before and * after a rest action is performed. After this the LM7A sensor is * set in the interrupt or the comparator mode. * * @param[in] i2c_interface the i2c interface, several interfaces * can be selected: i2c0, i2c1 and i2c2. * @param[in] baud_rate the baud rate. * @param[in] external_interr_handler pointer to a handler for the external * interrupt. * * @return true if the I2C interface and the external interrupt handler are * successfully initialized, otherwise false. */ bool lm75A_init(uint8_t i2c_interface, uint32_t baud_rate, void *external_interr_handler); /** * @brief Register the external interrupt handler for the over-temperature * shutdown output. * * @param[in] handler pointer to a handler for the external interrupts. * * @return true if the the external interrupt handler is successfully * registered, otherwise false. */ bool lm75A_external_interrupt_register(void *handler); /** * @brief Alarm the sensor sampling task about an external interrupt. * * @param[in] b is true if an external interrupt is occurred, otherwise false. * */ void lm75A_set_in_alarm(bool b); #ifdef __cplusplus } #endif /** @} */ #endif /* LM75A_H_ */