Driver for FXPQ3115 sensor.

Example usage

main.cpp

#include "mbed.h"
#include "FXPQ3115.h"

FXPQ3115 pressure_sensor(P0_13, P0_14);

int main()
{
    pressure_sensor.sensor_init();

    while (1) {
        pressure_sensor.read_oneshotMode_bar();
        printf("Pressure in Pascals: %d\n", pressure_sensor.print_pressure());
        thread_sleep_for(20000);
    }
}
Revision:
0:0b221579ed52
diff -r 000000000000 -r 0b221579ed52 FXPQ3115.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXPQ3115.h	Thu Mar 05 11:13:50 2020 +0100
@@ -0,0 +1,39 @@
+#ifndef FXPQ3115_H_
+#define FXPQ3115_H_
+
+#include "mbed.h"
+#include "FXPQ3115_reg.h"
+
+#ifndef SUCCESS
+#define SUCCESS 0
+#endif
+
+#ifndef FAILURE
+#define FAILURE 1
+#endif
+
+#ifdef FXPQ3115_I2C_ADDRESS
+#define FXPQ3115_I2C_ADDRESS_SHIFTED (FXPQ3115_I2C_ADDRESS << 1)
+#endif
+
+#define FXPQ3115_PRESSURE_CONV_FACTOR (64)     /* Will give Pascals */
+#define FXPQ3115_ALTITUDE_CONV_FACTOR (65536)  /* Will give meters above MSL */
+#define FXPQ3115_TEMPERATURE_CONV_FACTOR (256) /* Will give °C */
+
+class FXPQ3115 {
+    public:
+        FXPQ3115(PinName sda, PinName scl);
+
+        uint8_t sensor_init();
+        uint8_t read_oneshotMode_bar();
+        uint32_t print_pressure();
+
+    private:
+        I2C _i2c;
+        char _bar_data[3];
+
+        uint8_t _config_bar();
+        uint8_t _wait_for_acq();
+};
+
+#endif // FXPQ3115_H_