SCP1000-D01 MEMS pressure sensor library

Committer:
MichaelW
Date:
Tue Sep 28 08:28:48 2010 +0000
Revision:
4:d509ab38e2b5
Parent:
3:29c98bdee20b
Code improvements

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 2:076ba33b1895 25 * Library for using the SCP1000-D01 MEMS Pressure sensor
MichaelW 0:dfe5ae6ea375 26 *
MichaelW 0:dfe5ae6ea375 27 */
MichaelW 0:dfe5ae6ea375 28
MichaelW 0:dfe5ae6ea375 29 #ifndef SCP1000_D01_H_
MichaelW 0:dfe5ae6ea375 30 #define SCP1000_D01_H_
MichaelW 4:d509ab38e2b5 31 /**
MichaelW 4:d509ab38e2b5 32 * Includes
MichaelW 4:d509ab38e2b5 33 */
MichaelW 0:dfe5ae6ea375 34 #include "mbed.h"
MichaelW 0:dfe5ae6ea375 35 /**
MichaelW 0:dfe5ae6ea375 36 * Class to allow reading of the SCP1000-D01 mems pressure sensor (SPI mode). The class currently only supports High resolution mode.
MichaelW 2:076ba33b1895 37 * This means that the sensor can be read at a maximum rate of 1.8Hz.
MichaelW 0:dfe5ae6ea375 38 */
MichaelW 0:dfe5ae6ea375 39 class SCP1000{
MichaelW 3:29c98bdee20b 40 public:
MichaelW 0:dfe5ae6ea375 41 /**
MichaelW 0:dfe5ae6ea375 42 *Constructor
MichaelW 0:dfe5ae6ea375 43 *
MichaelW 0:dfe5ae6ea375 44 * @param mosi The MOSI pin for the SPI interface
MichaelW 0:dfe5ae6ea375 45 * @param miso The MISO pin for the SPI interface
MichaelW 0:dfe5ae6ea375 46 * @param CSB The Chip select on the SCP1000
MichaelW 0:dfe5ae6ea375 47 */
MichaelW 0:dfe5ae6ea375 48 SCP1000(PinName mosi, PinName miso, PinName sck, PinName CSB);
MichaelW 0:dfe5ae6ea375 49
MichaelW 0:dfe5ae6ea375 50 /**
MichaelW 4:d509ab38e2b5 51 * Read the current Pressure.
MichaelW 4:d509ab38e2b5 52 * This blocks until the sensor has completed a reading
MichaelW 0:dfe5ae6ea375 53 *
MichaelW 4:d509ab38e2b5 54 * @returns The pressure in pascals (N/m2)
MichaelW 0:dfe5ae6ea375 55 */
MichaelW 0:dfe5ae6ea375 56 float read();
MichaelW 0:dfe5ae6ea375 57 /**
MichaelW 0:dfe5ae6ea375 58 * Reads the temperature as measured by the SCP1000.
MichaelW 0:dfe5ae6ea375 59 * This blocks until the sensor has completed a reading
MichaelW 0:dfe5ae6ea375 60 *
MichaelW 4:d509ab38e2b5 61 *@returns The temperature in degrees celsius
MichaelW 0:dfe5ae6ea375 62 */
MichaelW 0:dfe5ae6ea375 63 float readTemperature();
MichaelW 0:dfe5ae6ea375 64
MichaelW 0:dfe5ae6ea375 65
MichaelW 0:dfe5ae6ea375 66
MichaelW 0:dfe5ae6ea375 67 private:
MichaelW 2:076ba33b1895 68 /**
MichaelW 2:076ba33b1895 69 * Method which blocks until the sensor is ready to be read.
MichaelW 4:d509ab38e2b5 70 * @returns 1 when successful.
MichaelW 2:076ba33b1895 71 */
MichaelW 2:076ba33b1895 72 int _waitReady();
MichaelW 0:dfe5ae6ea375 73 //Interfaces
MichaelW 0:dfe5ae6ea375 74 SPI _spi;
MichaelW 0:dfe5ae6ea375 75 DigitalOut _CSB;
MichaelW 3:29c98bdee20b 76
MichaelW 3:29c98bdee20b 77 //Pins that woudl be required to use SCP1000 in different modes
MichaelW 2:076ba33b1895 78 // DigitalIn _DRDY; //Interrupt data ready - also need to be able to attach a function to this class
MichaelW 0:dfe5ae6ea375 79 // DigitalOut _TRIG; //Trigger
MichaelW 2:076ba33b1895 80 // DigitalOut _PD; //Power Down
MichaelW 0:dfe5ae6ea375 81
MichaelW 0:dfe5ae6ea375 82
MichaelW 0:dfe5ae6ea375 83 };
MichaelW 0:dfe5ae6ea375 84 #endif