Capacitive digital sensor for relative humidity and temperature.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: HelloWorld_ST_Sensors MOTENV_Mbed mbed-os-mqtt-client HTS221_JS ... more
Revision 1:c4391f20553e, committed 2017-09-27
- Comitter:
- mapellil
- Date:
- Wed Sep 27 16:36:58 2017 +0200
- Parent:
- 0:7917d6d00a6e
- Child:
- 2:312ee2694a77
- Commit message:
- Fixed NonCopyable
Changed in this revision
HTS221Sensor.cpp | Show annotated file Show diff for this revision Revisions of this file |
HTS221Sensor.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/HTS221Sensor.cpp Mon Sep 04 16:06:23 2017 +0000 +++ b/HTS221Sensor.cpp Wed Sep 27 16:36:58 2017 +0200 @@ -48,19 +48,10 @@ * @param i2c object of an helper class which handles the I2C peripheral * @param address the address of the component's instance */ -HTS221Sensor::HTS221Sensor(DevI2C &i2c) : _dev_i2c(i2c) +HTS221Sensor::HTS221Sensor(DevI2C *i2c, uint8_t address, PinName drdy_pin) : + _dev_i2c(i2c), _address(address), _cs_pin(NC), _drdy_pin(drdy_pin) { - _address = HTS221_I2C_ADDRESS; -}; - - -/** Constructor - * @param i2c object of an helper class which handles the I2C peripheral - * @param address the address of the component's instance - */ -HTS221Sensor::HTS221Sensor(DevI2C &i2c, uint8_t address) : _dev_i2c(i2c), _address(address) -{ - + assert (i2c); }; /**
--- a/HTS221Sensor.h Mon Sep 04 16:06:23 2017 +0000 +++ b/HTS221Sensor.h Wed Sep 27 16:36:58 2017 +0200 @@ -48,7 +48,7 @@ #include "HTS221_driver.h" #include "HumiditySensor.h" #include "TempSensor.h" - +#include <assert.h> /* Class Declaration ---------------------------------------------------------*/ @@ -58,9 +58,7 @@ class HTS221Sensor : public HumiditySensor, public TempSensor { public: - - HTS221Sensor(DevI2C &i2c); - HTS221Sensor(DevI2C &i2c, uint8_t address); + HTS221Sensor(DevI2C *i2c, uint8_t address=HTS221_I2C_ADDRESS, PinName drdy_pin=NC); virtual int init(void *init); virtual int read_id(uint8_t *id); virtual int get_humidity(float *pfData); @@ -81,7 +79,7 @@ */ uint8_t io_read(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead) { - return (uint8_t) _dev_i2c.i2c_read(pBuffer, _address, RegisterAddr, NumByteToRead); + return (uint8_t) _dev_i2c->i2c_read(pBuffer, _address, RegisterAddr, NumByteToRead); } /** @@ -93,17 +91,18 @@ */ uint8_t io_write(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite) { - return (uint8_t) _dev_i2c.i2c_write(pBuffer, _address, RegisterAddr, NumByteToWrite); + return (uint8_t) _dev_i2c->i2c_write(pBuffer, _address, RegisterAddr, NumByteToWrite); } private: /* Helper classes. */ - DevI2C &_dev_i2c; + DevI2C *_dev_i2c; /* Configuration */ uint8_t _address; - + DigitalOut _cs_pin; + InterruptIn _drdy_pin; }; #ifdef __cplusplus