EVE 1.0
temp-sensor-stlm75.h
Go to the documentation of this file.
1 #ifndef DRIVER_TEMPERATURE_SENSOR_STLM75_H
2 #define DRIVER_TEMPERATURE_SENSOR_STLM75_H
3 /**********************************************************************/
4 /*
5  * Copyright (c) 2014, Jetro AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  * 3. The name of the author may not be used to endorse or promote products
17  * derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONRIBUTORS ``AS IS'' AND ANY EXPRESS
20  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
22  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
28  * OF SUCH DAMAGE.
29  *
30  * This file is part of the EVE platform.
31  */
32 
33 /**
34  * \file
35  * @brief Driver for I2C-based temperature sensor type ST STLM75.
36  *
37  * @author KLO, Jetro AS
38  */ /******************************************************************/
39 
40 #include <dev/i2c-master.h>
41 
42 /**
43  * \defgroup stlm75 ST STLM75 temperature sensor driver
44  * \ingroup extdrv
45  * \{
46  *
47  * This driver supports the I2C-based temperature sensor type ST STLM75.
48  * The temperature sensor accuracy is typical ±0.5°C from -55°C to +125°C
49  * (max ±2°C from -25°C to +100°C, max ±3°C from -55°C to +125°C).
50  * Temperature convertion time is max 150ms.
51  * Temperature measurement range is from -55°C to +125°C.
52  *
53  * The temperature sensor has 3 address lines.
54  * The I2C address range is 0x48 - 0x4f. Max baudrate is 400 kbit/s.
55  * Typical current consumption (at 3.3V, 25°C) is 125µA in active mode and
56  * 1µA (max) in power down mode.
57  *
58  * Both initialization and disabling of the sensor, and reading of
59  * temperature at 1.0°C resolution are supported.
60  *
61  * The selected I2C port must be initialized before using the driver.
62  */
63 
64 /***********************************************************************
65  * Global defines
66 ***********************************************************************/
67 /**
68  * temp_sensor_t structure holds I2C port and slave address to be used.
69  *
70  */
71 struct temp_sensor_t
72 {
73  const struct i2c_t *I2c;
74  uint8_t SlaveAddress;
75 };
76 
77 /**
78  * @name Functions called from application programs
79  * @{
80  */
81 
82 /**********************************************************************/
83 /**
84  * @brief Name: TempSensorInit\n
85  * Initializes the I2C-based temperature sensor for continously convertion.
86  * I2C address range is 0x48 - 0x4f. Max baudrate is 400 kbit/s.
87  * Temperature convertion time is max 150ms.
88  * Temperature measurement range is from -55°C to +125°C.
89  * Typical current consumption (@ 3.3V, 25°C) is 125µA.
90  *
91  * @param TempSensor Parameters for the temperature sensor to be used
92  * @return true if OK, else false
93  ***********************************************************************/
94 extern bool TempSensorInit(const struct temp_sensor_t *TempSensor);
95 
96 /**********************************************************************/
97 /**
98  * @brief Name: TempSensorDisable\n
99  * Disables and powers down the I2C-based temperature sensor.
100  * Typical current consumption is 1µA (max) in power down mode.
101  *
102  * @param TempSensor Parameters for the temperature sensor to be used
103  * @return true if OK, else false
104  ***********************************************************************/
105 extern bool TempSensorDisable(const struct temp_sensor_t *TempSensor);
106 
107 /**********************************************************************/
108 /**
109  * @brief Name: TempSensorGet\n
110  * Reads temperature value from temperature sensor. Resolution 1.0°C.
111  *
112  * @param TempSensor Parameters for the temperature sensor to be used
113  * @param Value Pointer to where to put the temperature value (int8_t)
114  * @return true if OK, else false
115  ***********************************************************************/
116 extern bool TempSensorGet(const struct temp_sensor_t *TempSensor, int8_t *Value);
117 
118 /** @} */
119 /** \} */
120 
121 #endif //DRIVER_TEMPERATURE_SENSOR_STLM75_H
bool TempSensorDisable(const struct temp_sensor_t *TempSensor)
Name: TempSensorDisable Disables and powers down the I2C-based temperature sensor. Typical current consumption is 1µA (max) in power down mode.
Driver for I2C in nRF52 uC.
bool TempSensorGet(const struct temp_sensor_t *TempSensor, int8_t *Value)
Name: TempSensorGet Reads temperature value from temperature sensor. Resolution 1.0°C.
bool TempSensorInit(const struct temp_sensor_t *TempSensor)
Name: TempSensorInit Initializes the I2C-based temperature sensor for continously convertion...