fork of TMP102, added read_u16 functionality

Fork of TMP102 by Chris Styles

Committer:
atarbey
Date:
Thu Dec 08 11:07:51 2016 +0000
Revision:
5:4169d23725c6
Parent:
4:0319e5fee951
Fix uncompatible datatype uint / int

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:374d9678d5ad 1
chris 0:374d9678d5ad 2 /*
chris 0:374d9678d5ad 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
chris 0:374d9678d5ad 4
chris 0:374d9678d5ad 5 Permission is hereby granted, free of charge, to any person obtaining a copy
chris 0:374d9678d5ad 6 of this software and associated documentation files (the "Software"), to deal
chris 0:374d9678d5ad 7 in the Software without restriction, including without limitation the rights
chris 0:374d9678d5ad 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
chris 0:374d9678d5ad 9 copies of the Software, and to permit persons to whom the Software is
chris 0:374d9678d5ad 10 furnished to do so, subject to the following conditions:
chris 0:374d9678d5ad 11
chris 0:374d9678d5ad 12 The above copyright notice and this permission notice shall be included in
chris 0:374d9678d5ad 13 all copies or substantial portions of the Software.
chris 0:374d9678d5ad 14
chris 0:374d9678d5ad 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
chris 0:374d9678d5ad 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
chris 0:374d9678d5ad 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
chris 0:374d9678d5ad 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
chris 0:374d9678d5ad 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
chris 0:374d9678d5ad 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
chris 0:374d9678d5ad 21 THE SOFTWARE.
chris 0:374d9678d5ad 22 */
chris 0:374d9678d5ad 23
chris 0:374d9678d5ad 24 #ifndef TMP102_H
chris 0:374d9678d5ad 25 #define TMP102_H
chris 0:374d9678d5ad 26
chris 0:374d9678d5ad 27 #include "mbed.h"
chris 0:374d9678d5ad 28
chris 0:374d9678d5ad 29 //!Library for the TI TMP102 temperature sensor.
chris 0:374d9678d5ad 30 /*!
chris 0:374d9678d5ad 31 The TMP102 is an I2C digital temperature sensor in a small SOT563 package, with a 0.0625C resolution and 0.5C accuracy.
chris 0:374d9678d5ad 32 */
chris 0:374d9678d5ad 33 class TMP102
chris 0:374d9678d5ad 34 {
chris 0:374d9678d5ad 35 public:
chris 0:374d9678d5ad 36 //!Creates an instance of the class.
chris 0:374d9678d5ad 37 /*!
chris 0:374d9678d5ad 38 Connect module at I2C address addr using I2C port pins sda and scl.
chris 0:374d9678d5ad 39 TMP102
chris 0:374d9678d5ad 40 \param addr <table><tr><th>A0 pin connection</th><th>Address</th></tr><tr><td>GND</td><td>0x90</td></tr><tr><td>V+</td><td>0x92</td></tr><tr><td>SDA</td><td>0x94</td></tr><tr><td>SCL</td><td>0x96</td></tr></table>
chris 0:374d9678d5ad 41 */
chris 0:374d9678d5ad 42 TMP102(PinName sda, PinName scl, int addr);
chris 0:374d9678d5ad 43
chris 0:374d9678d5ad 44 /*!
chris 0:374d9678d5ad 45 Destroys instance.
chris 0:374d9678d5ad 46 */
chris 0:374d9678d5ad 47 ~TMP102();
chris 0:374d9678d5ad 48
atarbey 4:0319e5fee951 49
atarbey 4:0319e5fee951 50 //!Reads the unprocessed current temperature (16 bit).
atarbey 4:0319e5fee951 51 /*!
atarbey 4:0319e5fee951 52 Reads the temperature register of the TMP102
atarbey 4:0319e5fee951 53 */
atarbey 5:4169d23725c6 54 int16_t read_u16();
atarbey 4:0319e5fee951 55
chris 0:374d9678d5ad 56 //!Reads the current temperature.
chris 0:374d9678d5ad 57 /*!
chris 0:374d9678d5ad 58 Reads the temperature register of the TMP102 and converts it to a useable value.
chris 0:374d9678d5ad 59 */
chris 0:374d9678d5ad 60 float read();
chris 0:374d9678d5ad 61
chris 0:374d9678d5ad 62 private:
chris 0:374d9678d5ad 63 I2C m_i2c;
chris 0:374d9678d5ad 64 int m_addr;
chris 0:374d9678d5ad 65
chris 0:374d9678d5ad 66 };
chris 0:374d9678d5ad 67
chris 0:374d9678d5ad 68 #endif