SCP1000-D01 MEMS pressure sensor library
scp1000.h@0:dfe5ae6ea375, 2010-09-27 (annotated)
- Committer:
- MichaelW
- Date:
- Mon Sep 27 08:29:02 2010 +0000
- Revision:
- 0:dfe5ae6ea375
- Child:
- 1:a45810688644
Initial
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MichaelW | 0:dfe5ae6ea375 | 1 | /** |
MichaelW | 0:dfe5ae6ea375 | 2 | * |
MichaelW | 0:dfe5ae6ea375 | 3 | */ |
MichaelW | 0:dfe5ae6ea375 | 4 | |
MichaelW | 0:dfe5ae6ea375 | 5 | |
MichaelW | 0:dfe5ae6ea375 | 6 | |
MichaelW | 0:dfe5ae6ea375 | 7 | |
MichaelW | 0:dfe5ae6ea375 | 8 | //not sure whether to make this library and class specific to the spi but code compatible or to make it generic |
MichaelW | 0:dfe5ae6ea375 | 9 | |
MichaelW | 0:dfe5ae6ea375 | 10 | #ifndef SCP1000_D01_H_ |
MichaelW | 0:dfe5ae6ea375 | 11 | #define SCP1000_D01_H_ |
MichaelW | 0:dfe5ae6ea375 | 12 | |
MichaelW | 0:dfe5ae6ea375 | 13 | #include "mbed.h" |
MichaelW | 0:dfe5ae6ea375 | 14 | /** |
MichaelW | 0:dfe5ae6ea375 | 15 | * Class to allow reading of the SCP1000-D01 mems pressure sensor (SPI mode). The class currently only supports High resolution mode. |
MichaelW | 0:dfe5ae6ea375 | 16 | * This means that the snesor can be read at a maximum rate of 1.8Hz. |
MichaelW | 0:dfe5ae6ea375 | 17 | */ |
MichaelW | 0:dfe5ae6ea375 | 18 | class SCP1000{ |
MichaelW | 0:dfe5ae6ea375 | 19 | public: |
MichaelW | 0:dfe5ae6ea375 | 20 | |
MichaelW | 0:dfe5ae6ea375 | 21 | typedef enum SCPModes{HIGHRES, |
MichaelW | 0:dfe5ae6ea375 | 22 | HIGHSPEED, |
MichaelW | 0:dfe5ae6ea375 | 23 | ULTRALOWPOWER, |
MichaelW | 0:dfe5ae6ea375 | 24 | LOWPOWER, |
MichaelW | 0:dfe5ae6ea375 | 25 | POWERDOWN}SCPMode; |
MichaelW | 0:dfe5ae6ea375 | 26 | |
MichaelW | 0:dfe5ae6ea375 | 27 | |
MichaelW | 0:dfe5ae6ea375 | 28 | //Constructors - to be Overloaded for different read modes - ie different pins connected up |
MichaelW | 0:dfe5ae6ea375 | 29 | /** |
MichaelW | 0:dfe5ae6ea375 | 30 | *Constructor |
MichaelW | 0:dfe5ae6ea375 | 31 | * |
MichaelW | 0:dfe5ae6ea375 | 32 | * @param mosi The MOSI pin for the SPI interface |
MichaelW | 0:dfe5ae6ea375 | 33 | * @param miso The MISO pin for the SPI interface |
MichaelW | 0:dfe5ae6ea375 | 34 | * @param CSB The Chip select on the SCP1000 |
MichaelW | 0:dfe5ae6ea375 | 35 | */ |
MichaelW | 0:dfe5ae6ea375 | 36 | SCP1000(PinName mosi, PinName miso, PinName sck, PinName CSB); |
MichaelW | 0:dfe5ae6ea375 | 37 | |
MichaelW | 0:dfe5ae6ea375 | 38 | //Methods |
MichaelW | 0:dfe5ae6ea375 | 39 | void SetMode(SCPMode mode); |
MichaelW | 0:dfe5ae6ea375 | 40 | |
MichaelW | 0:dfe5ae6ea375 | 41 | /** |
MichaelW | 0:dfe5ae6ea375 | 42 | *Read the current Pressure. |
MichaelW | 0:dfe5ae6ea375 | 43 | *This blocks until the sensor has compelted a reading |
MichaelW | 0:dfe5ae6ea375 | 44 | * |
MichaelW | 0:dfe5ae6ea375 | 45 | * @returns The pressure in pascals |
MichaelW | 0:dfe5ae6ea375 | 46 | */ |
MichaelW | 0:dfe5ae6ea375 | 47 | float read(); |
MichaelW | 0:dfe5ae6ea375 | 48 | /** |
MichaelW | 0:dfe5ae6ea375 | 49 | * Reads the temperature as measured by the SCP1000. |
MichaelW | 0:dfe5ae6ea375 | 50 | * This blocks until the sensor has completed a reading |
MichaelW | 0:dfe5ae6ea375 | 51 | * |
MichaelW | 0:dfe5ae6ea375 | 52 | *returns The temperature in degrees celsius |
MichaelW | 0:dfe5ae6ea375 | 53 | */ |
MichaelW | 0:dfe5ae6ea375 | 54 | float readTemperature(); |
MichaelW | 0:dfe5ae6ea375 | 55 | |
MichaelW | 0:dfe5ae6ea375 | 56 | |
MichaelW | 0:dfe5ae6ea375 | 57 | |
MichaelW | 0:dfe5ae6ea375 | 58 | private: |
MichaelW | 0:dfe5ae6ea375 | 59 | SCPMode _mode; |
MichaelW | 0:dfe5ae6ea375 | 60 | |
MichaelW | 0:dfe5ae6ea375 | 61 | int _isReady(); |
MichaelW | 0:dfe5ae6ea375 | 62 | |
MichaelW | 0:dfe5ae6ea375 | 63 | |
MichaelW | 0:dfe5ae6ea375 | 64 | //Interfaces |
MichaelW | 0:dfe5ae6ea375 | 65 | SPI _spi; |
MichaelW | 0:dfe5ae6ea375 | 66 | DigitalOut _CSB; |
MichaelW | 0:dfe5ae6ea375 | 67 | // DigitalIn _DRDY; //Interrupt data ready - also need to be able to attach a function to this class |
MichaelW | 0:dfe5ae6ea375 | 68 | // DigitalOut _TRIG; //Trigger |
MichaelW | 0:dfe5ae6ea375 | 69 | // DigitalOut _PD; //Power Down |
MichaelW | 0:dfe5ae6ea375 | 70 | |
MichaelW | 0:dfe5ae6ea375 | 71 | |
MichaelW | 0:dfe5ae6ea375 | 72 | }; |
MichaelW | 0:dfe5ae6ea375 | 73 | #endif |