SCP1000-D01 MEMS pressure sensor library

Committer:
MichaelW
Date:
Mon Sep 27 11:43:27 2010 +0000
Revision:
3:29c98bdee20b
Parent:
2:076ba33b1895
Child:
4:d509ab38e2b5
Code tidied up

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