ST / LPS22HB

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   HelloWorld_ST_Sensors MOTENV_Mbed mbed-os-mqtt-client LPS22HB_JS ... more

Files at this revision

API Documentation at this revision

Comitter:
mapellil
Date:
Wed Sep 27 16:49:30 2017 +0200
Parent:
0:3de9cb936fd1
Child:
2:f7b403c70f6b
Commit message:
Fixed NonCopyable

Changed in this revision

LPS22HBSensor.cpp Show annotated file Show diff for this revision Revisions of this file
LPS22HBSensor.h Show annotated file Show diff for this revision Revisions of this file
--- a/LPS22HBSensor.cpp	Mon Sep 04 16:06:45 2017 +0000
+++ b/LPS22HBSensor.cpp	Wed Sep 27 16:49:30 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
  */
-LPS22HBSensor::LPS22HBSensor(DevI2C &i2c) : _dev_i2c(i2c)
+LPS22HBSensor::LPS22HBSensor(DevI2C *i2c, uint8_t address, PinName int_pin) : 
+                            _dev_i2c(i2c), _address(address), _cs_pin(NC), _int_pin(int_pin)
 {
-  _address = LPS22HB_ADDRESS_HIGH;
-};
-
-
-/** Constructor
- * @param i2c object of an helper class which handles the I2C peripheral
- * @param address the address of the component's instance
- */
-LPS22HBSensor::LPS22HBSensor(DevI2C &i2c, uint8_t address) : _dev_i2c(i2c), _address(address)
-{
-
+    assert (i2c);
 };
 
 /**
--- a/LPS22HBSensor.h	Mon Sep 04 16:06:45 2017 +0000
+++ b/LPS22HBSensor.h	Wed Sep 27 16:49:30 2017 +0200
@@ -48,6 +48,7 @@
 #include "LPS22HB_driver.h"
 #include "PressureSensor.h"
 #include "TempSensor.h"
+#include <assert.h>
 
 /* Class Declaration ---------------------------------------------------------*/
 
@@ -57,8 +58,7 @@
 class LPS22HBSensor : public PressureSensor, public TempSensor
 {
   public:
-    LPS22HBSensor(DevI2C &i2c);
-    LPS22HBSensor(DevI2C &i2c, uint8_t address);
+    LPS22HBSensor(DevI2C *i2c, uint8_t address=LPS22HB_ADDRESS_HIGH, PinName int_pin=NC);
     virtual int init(void *init);
     virtual int read_id(uint8_t *id);
     virtual int get_pressure(float *pfData);
@@ -80,7 +80,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);
     }
     
     /**
@@ -92,7 +92,7 @@
      */
     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:
@@ -100,10 +100,12 @@
     int Set_ODR_When_Disabled(float odr);
 
     /* Helper classes. */
-    DevI2C &_dev_i2c;
+    DevI2C *_dev_i2c;
     
     /* Configuration */
     uint8_t _address;
+    DigitalOut  _cs_pin; 
+    InterruptIn _int_pin;    
     
     uint8_t _is_enabled;
     float _last_odr;