SCP1000-D01 MEMS pressure sensor library

Committer:
MichaelW
Date:
Mon Sep 27 08:30:39 2010 +0000
Revision:
1:a45810688644
Parent:
0:dfe5ae6ea375
Child:
2:076ba33b1895
License info added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MichaelW 0:dfe5ae6ea375 1 /**
MichaelW 1:a45810688644 2 * @section LICENSE
MichaelW 1:a45810688644 3 *Copyright (c) 2010 ARM Ltd.
MichaelW 1:a45810688644 4 *
MichaelW 1:a45810688644 5 *Permission is hereby granted, free of charge, to any person obtaining a copy
MichaelW 1:a45810688644 6 *of this software and associated documentation files (the "Software"), to deal
MichaelW 1:a45810688644 7 *in the Software without restriction, including without limitation the rights
MichaelW 1:a45810688644 8 *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
MichaelW 1:a45810688644 9 *copies of the Software, and to permit persons to whom the Software is
MichaelW 1:a45810688644 10 *furnished to do so, subject to the following conditions:
MichaelW 1:a45810688644 11 *
MichaelW 1:a45810688644 12 *The above copyright notice and this permission notice shall be included in
MichaelW 1:a45810688644 13 *all copies or substantial portions of the Software.
MichaelW 1:a45810688644 14 *
MichaelW 1:a45810688644 15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
MichaelW 1:a45810688644 16 *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
MichaelW 1:a45810688644 17 *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
MichaelW 1:a45810688644 18 *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
MichaelW 1:a45810688644 19 *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
MichaelW 1:a45810688644 20 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
MichaelW 1:a45810688644 21 *THE SOFTWARE.
MichaelW 1:a45810688644 22 *
MichaelW 1:a45810688644 23 *
MichaelW 1:a45810688644 24 * @section DESCRIPTION
MichaelW 1:a45810688644 25 *
MichaelW 0:dfe5ae6ea375 26 *
MichaelW 0:dfe5ae6ea375 27 */
MichaelW 0:dfe5ae6ea375 28
MichaelW 0:dfe5ae6ea375 29
MichaelW 0:dfe5ae6ea375 30 #ifndef SCP1000_D01_H_
MichaelW 0:dfe5ae6ea375 31 #define SCP1000_D01_H_
MichaelW 0:dfe5ae6ea375 32
MichaelW 0:dfe5ae6ea375 33 #include "mbed.h"
MichaelW 0:dfe5ae6ea375 34 /**
MichaelW 0:dfe5ae6ea375 35 * Class to allow reading of the SCP1000-D01 mems pressure sensor (SPI mode). The class currently only supports High resolution mode.
MichaelW 0:dfe5ae6ea375 36 * This means that the snesor can be read at a maximum rate of 1.8Hz.
MichaelW 0:dfe5ae6ea375 37 */
MichaelW 0:dfe5ae6ea375 38 class SCP1000{
MichaelW 0:dfe5ae6ea375 39 public:
MichaelW 0:dfe5ae6ea375 40
MichaelW 0:dfe5ae6ea375 41 typedef enum SCPModes{HIGHRES,
MichaelW 0:dfe5ae6ea375 42 HIGHSPEED,
MichaelW 0:dfe5ae6ea375 43 ULTRALOWPOWER,
MichaelW 0:dfe5ae6ea375 44 LOWPOWER,
MichaelW 0:dfe5ae6ea375 45 POWERDOWN}SCPMode;
MichaelW 0:dfe5ae6ea375 46
MichaelW 0:dfe5ae6ea375 47
MichaelW 0:dfe5ae6ea375 48 //Constructors - to be Overloaded for different read modes - ie different pins connected up
MichaelW 0:dfe5ae6ea375 49 /**
MichaelW 0:dfe5ae6ea375 50 *Constructor
MichaelW 0:dfe5ae6ea375 51 *
MichaelW 0:dfe5ae6ea375 52 * @param mosi The MOSI pin for the SPI interface
MichaelW 0:dfe5ae6ea375 53 * @param miso The MISO pin for the SPI interface
MichaelW 0:dfe5ae6ea375 54 * @param CSB The Chip select on the SCP1000
MichaelW 0:dfe5ae6ea375 55 */
MichaelW 0:dfe5ae6ea375 56 SCP1000(PinName mosi, PinName miso, PinName sck, PinName CSB);
MichaelW 0:dfe5ae6ea375 57
MichaelW 0:dfe5ae6ea375 58 //Methods
MichaelW 0:dfe5ae6ea375 59 void SetMode(SCPMode mode);
MichaelW 0:dfe5ae6ea375 60
MichaelW 0:dfe5ae6ea375 61 /**
MichaelW 0:dfe5ae6ea375 62 *Read the current Pressure.
MichaelW 0:dfe5ae6ea375 63 *This blocks until the sensor has compelted a reading
MichaelW 0:dfe5ae6ea375 64 *
MichaelW 0:dfe5ae6ea375 65 * @returns The pressure in pascals
MichaelW 0:dfe5ae6ea375 66 */
MichaelW 0:dfe5ae6ea375 67 float read();
MichaelW 0:dfe5ae6ea375 68 /**
MichaelW 0:dfe5ae6ea375 69 * Reads the temperature as measured by the SCP1000.
MichaelW 0:dfe5ae6ea375 70 * This blocks until the sensor has completed a reading
MichaelW 0:dfe5ae6ea375 71 *
MichaelW 0:dfe5ae6ea375 72 *returns The temperature in degrees celsius
MichaelW 0:dfe5ae6ea375 73 */
MichaelW 0:dfe5ae6ea375 74 float readTemperature();
MichaelW 0:dfe5ae6ea375 75
MichaelW 0:dfe5ae6ea375 76
MichaelW 0:dfe5ae6ea375 77
MichaelW 0:dfe5ae6ea375 78 private:
MichaelW 0:dfe5ae6ea375 79 SCPMode _mode;
MichaelW 0:dfe5ae6ea375 80
MichaelW 0:dfe5ae6ea375 81 int _isReady();
MichaelW 0:dfe5ae6ea375 82
MichaelW 0:dfe5ae6ea375 83
MichaelW 0:dfe5ae6ea375 84 //Interfaces
MichaelW 0:dfe5ae6ea375 85 SPI _spi;
MichaelW 0:dfe5ae6ea375 86 DigitalOut _CSB;
MichaelW 0:dfe5ae6ea375 87 // DigitalIn _DRDY; //Interrupt data ready - also need to be able to attach a function to this class
MichaelW 0:dfe5ae6ea375 88 // DigitalOut _TRIG; //Trigger
MichaelW 0:dfe5ae6ea375 89 // DigitalOut _PD; //Power Down
MichaelW 0:dfe5ae6ea375 90
MichaelW 0:dfe5ae6ea375 91
MichaelW 0:dfe5ae6ea375 92 };
MichaelW 0:dfe5ae6ea375 93 #endif