fork of TMP102, added read_u16 functionality
Fork of TMP102 by
Revision 4:0319e5fee951, committed 2016-12-08
- Comitter:
- atarbey
- Date:
- Thu Dec 08 10:59:34 2016 +0000
- Parent:
- 3:694792b93731
- Child:
- 5:4169d23725c6
- Commit message:
- added read_u16()
Changed in this revision
TMP102.cpp | Show annotated file Show diff for this revision Revisions of this file |
TMP102.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/TMP102.cpp Thu Mar 07 10:44:42 2013 +0000 +++ b/TMP102.cpp Thu Dec 08 10:59:34 2016 +0000 @@ -35,6 +35,19 @@ } +int16_t TMP102::read_u16() +{ + const char tempRegAddr = TEMP_REG_ADDR; + + m_i2c.write(m_addr, &tempRegAddr, 1); //Pointer to the temperature register + + char reg[2] = {0,0}; + m_i2c.read(m_addr, reg, 2); //Rea + + int16_t res = ((int8_t)reg[0] << 4) | ((uint8_t)reg[1] >> 4); + return res; +} + float TMP102::read() { @@ -51,3 +64,6 @@ return temp; } + + +
--- a/TMP102.h Thu Mar 07 10:44:42 2013 +0000 +++ b/TMP102.h Thu Dec 08 10:59:34 2016 +0000 @@ -46,6 +46,13 @@ */ ~TMP102(); + + //!Reads the unprocessed current temperature (16 bit). + /*! + Reads the temperature register of the TMP102 + */ + uint16_t read_u16(); + //!Reads the current temperature. /*! Reads the temperature register of the TMP102 and converts it to a useable value.