Example of hello world for X-NUCLEO-IKS01A2

Dependencies:   X_NUCLEO_IKS01A2 mbed

Fork of HelloWorld_IKS01A2 by ST Expansion SW Team

Hello World Demo Application based on sensor expansion board X-NUCLEO-IKS01A2

Main function is to show how to get humidity, temperature, pressure, accelerometer, magnetomer and gyroscope data using the sensor expansion board and send them using UART to a connected PC or Desktop and display it on terminal applications like TeraTerm.

Revision:
2:f23b144da50a
Parent:
0:69566eea0fba
--- a/X_NUCLEO_IKS01A2/Components/LPS22HBSensor/LPS22HBSensor.h	Fri Aug 12 13:57:55 2016 +0000
+++ b/X_NUCLEO_IKS01A2/Components/LPS22HBSensor/LPS22HBSensor.h	Fri Aug 19 12:13:37 2016 +0000
@@ -46,37 +46,30 @@
 
 #include "DevI2C.h"
 #include "LPS22HB_Driver.h"
-
-/* Typedefs ------------------------------------------------------------------*/
-typedef enum
-{
-  LPS22HB_STATUS_OK = 0,
-  LPS22HB_STATUS_ERROR,
-  LPS22HB_STATUS_TIMEOUT,
-  LPS22HB_STATUS_NOT_IMPLEMENTED
-} LPS22HBStatusTypeDef;
-
+#include "PressureSensor.h"
+#include "TempSensor.h"
 
 /* Class Declaration ---------------------------------------------------------*/
 
 /**
  * Abstract class of an LPS22HB Pressure sensor.
  */
-class LPS22HBSensor
+class LPS22HBSensor : public PressureSensor, public TempSensor
 {
   public:
-    LPS22HBSensor                       (DevI2C &i2c);
-    LPS22HBSensor                       (DevI2C &i2c, uint8_t address);
-    LPS22HBStatusTypeDef Enable         (void);
-    LPS22HBStatusTypeDef Disable        (void);
-    LPS22HBStatusTypeDef ReadID         (uint8_t *ht_id);
-    LPS22HBStatusTypeDef Reset          (void);
-    LPS22HBStatusTypeDef GetPressure    (float *pfData);
-    LPS22HBStatusTypeDef GetTemperature (float *pfData);
-    LPS22HBStatusTypeDef GetODR         (float *odr);
-    LPS22HBStatusTypeDef SetODR         (float odr);
-    LPS22HBStatusTypeDef ReadReg        (uint8_t reg, uint8_t *data);
-    LPS22HBStatusTypeDef WriteReg       (uint8_t reg, uint8_t data);
+    LPS22HBSensor(DevI2C &i2c);
+    LPS22HBSensor(DevI2C &i2c, uint8_t address);
+    virtual int Init(void *init);
+    virtual int ReadID(uint8_t *id);
+    virtual int GetPressure(float *pfData);
+    virtual int GetTemperature(float *pfData);
+    int Enable(void);
+    int Disable(void);
+    int Reset(void);
+    int Get_ODR(float *odr);
+    int Set_ODR(float odr);
+    int ReadReg(uint8_t reg, uint8_t *data);
+    int WriteReg(uint8_t reg, uint8_t data);
     
     /**
      * @brief Utility function to read data.
@@ -103,8 +96,8 @@
     }
 
   private:
-    LPS22HBStatusTypeDef SetODR_When_Enabled(float odr);
-    LPS22HBStatusTypeDef SetODR_When_Disabled(float odr);
+    int Set_ODR_When_Enabled(float odr);
+    int Set_ODR_When_Disabled(float odr);
 
     /* Helper classes. */
     DevI2C &dev_i2c;