This is a simple wrapper class for the MPL3115A5 pressure and temperature sensor. It allows either single readings for continuous readings using polling or interrupts. It also contains a wrapper class for mbed-rpc.

Committer:
rhourahane
Date:
Sun Mar 22 20:55:38 2015 +0000
Revision:
0:b12a7d396be9
Initial revision.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rhourahane 0:b12a7d396be9 1 #ifndef PRCMPL3115A2_H
rhourahane 0:b12a7d396be9 2 #define RPCMPL3115A2_H
rhourahane 0:b12a7d396be9 3
rhourahane 0:b12a7d396be9 4 #include "rpc.h"
rhourahane 0:b12a7d396be9 5 #include "mpl3115a2.h"
rhourahane 0:b12a7d396be9 6
rhourahane 0:b12a7d396be9 7 /// RPC wrapper class for MPL3115A2 driver class.
rhourahane 0:b12a7d396be9 8 /// This class provides a simple single shot interface to the
rhourahane 0:b12a7d396be9 9 /// MPL3115A2 allowing the user to get the altimeter/barometric
rhourahane 0:b12a7d396be9 10 /// mode and number of samples per reading.
rhourahane 0:b12a7d396be9 11 class RpcMPL3115A2 : public mbed::RPC {
rhourahane 0:b12a7d396be9 12 public:
rhourahane 0:b12a7d396be9 13 /// Create a new instance of the class using the specified pins for the I2C bus.
rhourahane 0:b12a7d396be9 14 /// @param sda The pin name for the sda line of the I2C bus.
rhourahane 0:b12a7d396be9 15 /// @param scl The pin name for the scl line of the I2C bus.
rhourahane 0:b12a7d396be9 16 RpcMPL3115A2(PinName sda, PinName scl, const char *name=NULL);
rhourahane 0:b12a7d396be9 17
rhourahane 0:b12a7d396be9 18 /// Read the chip id, this is a fixed value of 0xC4. This method is
rhourahane 0:b12a7d396be9 19 /// linked to the RPC method method "id".
rhourahane 0:b12a7d396be9 20 /// @returns Chip id.
rhourahane 0:b12a7d396be9 21 int id(void);
rhourahane 0:b12a7d396be9 22
rhourahane 0:b12a7d396be9 23 /// Set the how the pressure is read. The default is BarometricMode if
rhourahane 0:b12a7d396be9 24 /// it is to be change then is must be called before getReadings or activate.
rhourahane 0:b12a7d396be9 25 /// This method is linked to to the RPC method "writeMode".
rhourahane 0:b12a7d396be9 26 /// @param mode New mode to read pressure in.
rhourahane 0:b12a7d396be9 27 void setMode(int mode);
rhourahane 0:b12a7d396be9 28
rhourahane 0:b12a7d396be9 29 /// Get the current setting for the pressure reading mode.
rhourahane 0:b12a7d396be9 30 /// This method is linked to the RPC method "readMode".
rhourahane 0:b12a7d396be9 31 /// @returns Current pressure reading mode.
rhourahane 0:b12a7d396be9 32 int getMode(void);
rhourahane 0:b12a7d396be9 33
rhourahane 0:b12a7d396be9 34 /// Set the number of samples to be used for each reading.
rhourahane 0:b12a7d396be9 35 /// The number must be a power of two between 1 and 128.
rhourahane 0:b12a7d396be9 36 /// This method is linked to the RPC method "writeSamples".
rhourahane 0:b12a7d396be9 37 /// @param samples Number of samples per reading.
rhourahane 0:b12a7d396be9 38 void setOverSampling(int rate);
rhourahane 0:b12a7d396be9 39
rhourahane 0:b12a7d396be9 40 /// Get the number of samples to be used for each reading.
rhourahane 0:b12a7d396be9 41 /// This method is linked to the RPC method "readSamples".
rhourahane 0:b12a7d396be9 42 /// @returns Number of samples per reading.
rhourahane 0:b12a7d396be9 43 int getOverSampling();
rhourahane 0:b12a7d396be9 44
rhourahane 0:b12a7d396be9 45 /// Reads both pressure and temperature. Returns pressure
rhourahane 0:b12a7d396be9 46 /// in the units set by mode and the temperature in Celsius,
rhourahane 0:b12a7d396be9 47 /// the values are separated by a space.
rhourahane 0:b12a7d396be9 48 /// This method is linked to the RPC method "read".
rhourahane 0:b12a7d396be9 49 void read(Arguments*, Reply*);
rhourahane 0:b12a7d396be9 50
rhourahane 0:b12a7d396be9 51 /// Override of RPC method to return array of methods
rhourahane 0:b12a7d396be9 52 /// that can be called through RPC.
rhourahane 0:b12a7d396be9 53 /// @returns array of method structures terminated by a
rhourahane 0:b12a7d396be9 54 /// null structure.
rhourahane 0:b12a7d396be9 55 virtual const struct rpc_method *get_rpc_methods();
rhourahane 0:b12a7d396be9 56
rhourahane 0:b12a7d396be9 57 /// Override of RPC method to return the RPC name of the class
rhourahane 0:b12a7d396be9 58 /// for this object.
rhourahane 0:b12a7d396be9 59 /// @returns RPC name of class for this instance.
rhourahane 0:b12a7d396be9 60 virtual const char *get_rpc_class_name();
rhourahane 0:b12a7d396be9 61
rhourahane 0:b12a7d396be9 62 /// Get the predefined RPC class structure for this
rhourahane 0:b12a7d396be9 63 /// class. Allows using template to register class
rhourahane 0:b12a7d396be9 64 /// this RPC.
rhourahane 0:b12a7d396be9 65 /// @returns Point to RPC class information structure.
rhourahane 0:b12a7d396be9 66 static struct rpc_class *get_rpc_class();
rhourahane 0:b12a7d396be9 67
rhourahane 0:b12a7d396be9 68 private:
rhourahane 0:b12a7d396be9 69 MPL3115A2 chip;
rhourahane 0:b12a7d396be9 70 };
rhourahane 0:b12a7d396be9 71
rhourahane 0:b12a7d396be9 72 #endif