SCP1000-D01 MEMS pressure sensor library

Committer:
MichaelW
Date:
Mon Sep 27 09:13:32 2010 +0000
Revision:
2:076ba33b1895
Parent:
1:a45810688644
Child:
3:29c98bdee20b
Documentation 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 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 *Constructor
MichaelW 0:dfe5ae6ea375 49 *
MichaelW 0:dfe5ae6ea375 50 * @param mosi The MOSI pin for the SPI interface
MichaelW 0:dfe5ae6ea375 51 * @param miso The MISO pin for the SPI interface
MichaelW 0:dfe5ae6ea375 52 * @param CSB The Chip select on the SCP1000
MichaelW 0:dfe5ae6ea375 53 */
MichaelW 0:dfe5ae6ea375 54 SCP1000(PinName mosi, PinName miso, PinName sck, PinName CSB);
MichaelW 0:dfe5ae6ea375 55
MichaelW 2:076ba33b1895 56
MichaelW 0:dfe5ae6ea375 57 void SetMode(SCPMode mode);
MichaelW 0:dfe5ae6ea375 58
MichaelW 0:dfe5ae6ea375 59 /**
MichaelW 0:dfe5ae6ea375 60 *Read the current Pressure.
MichaelW 0:dfe5ae6ea375 61 *This blocks until the sensor has compelted a reading
MichaelW 0:dfe5ae6ea375 62 *
MichaelW 0:dfe5ae6ea375 63 * @returns The pressure in pascals
MichaelW 0:dfe5ae6ea375 64 */
MichaelW 0:dfe5ae6ea375 65 float read();
MichaelW 0:dfe5ae6ea375 66 /**
MichaelW 0:dfe5ae6ea375 67 * Reads the temperature as measured by the SCP1000.
MichaelW 0:dfe5ae6ea375 68 * This blocks until the sensor has completed a reading
MichaelW 0:dfe5ae6ea375 69 *
MichaelW 0:dfe5ae6ea375 70 *returns The temperature in degrees celsius
MichaelW 0:dfe5ae6ea375 71 */
MichaelW 0:dfe5ae6ea375 72 float readTemperature();
MichaelW 0:dfe5ae6ea375 73
MichaelW 0:dfe5ae6ea375 74
MichaelW 0:dfe5ae6ea375 75
MichaelW 0:dfe5ae6ea375 76 private:
MichaelW 0:dfe5ae6ea375 77 SCPMode _mode;
MichaelW 2:076ba33b1895 78 /**
MichaelW 2:076ba33b1895 79 * Method which blocks until the sensor is ready to be read.
MichaelW 2:076ba33b1895 80 * Returns 1 when successful.
MichaelW 2:076ba33b1895 81 */
MichaelW 2:076ba33b1895 82 int _waitReady();
MichaelW 0:dfe5ae6ea375 83 //Interfaces
MichaelW 0:dfe5ae6ea375 84 SPI _spi;
MichaelW 0:dfe5ae6ea375 85 DigitalOut _CSB;
MichaelW 2:076ba33b1895 86 // DigitalIn _DRDY; //Interrupt data ready - also need to be able to attach a function to this class
MichaelW 0:dfe5ae6ea375 87 // DigitalOut _TRIG; //Trigger
MichaelW 2:076ba33b1895 88 // DigitalOut _PD; //Power Down
MichaelW 0:dfe5ae6ea375 89
MichaelW 0:dfe5ae6ea375 90
MichaelW 0:dfe5ae6ea375 91 };
MichaelW 0:dfe5ae6ea375 92 #endif