SCP1000-D01 MEMS pressure sensor library
Embed:
(wiki syntax)
Show/hide line numbers
scp1000.h
00001 /** 00002 * @section LICENSE 00003 *Copyright (c) 2010 ARM Ltd. 00004 * 00005 *Permission is hereby granted, free of charge, to any person obtaining a copy 00006 *of this software and associated documentation files (the "Software"), to deal 00007 *in the Software without restriction, including without limitation the rights 00008 *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 *copies of the Software, and to permit persons to whom the Software is 00010 *furnished to do so, subject to the following conditions: 00011 * 00012 *The above copyright notice and this permission notice shall be included in 00013 *all copies or substantial portions of the Software. 00014 * 00015 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00019 *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00020 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00021 *THE SOFTWARE. 00022 * 00023 * 00024 * @section DESCRIPTION 00025 * Library for using the SCP1000-D01 MEMS Pressure sensor 00026 * 00027 */ 00028 00029 #ifndef SCP1000_D01_H_ 00030 #define SCP1000_D01_H_ 00031 /** 00032 * Includes 00033 */ 00034 #include "mbed.h" 00035 /** 00036 * Class to allow reading of the SCP1000-D01 mems pressure sensor (SPI mode). The class currently only supports High resolution mode. 00037 * This means that the sensor can be read at a maximum rate of 1.8Hz. 00038 */ 00039 class SCP1000{ 00040 public: 00041 /** 00042 *Constructor 00043 * 00044 * @param mosi The MOSI pin for the SPI interface 00045 * @param miso The MISO pin for the SPI interface 00046 * @param CSB The Chip select on the SCP1000 00047 */ 00048 SCP1000(PinName mosi, PinName miso, PinName sck, PinName CSB); 00049 00050 /** 00051 * Read the current Pressure. 00052 * This blocks until the sensor has completed a reading 00053 * 00054 * @returns The pressure in pascals (N/m2) 00055 */ 00056 float read(); 00057 /** 00058 * Reads the temperature as measured by the SCP1000. 00059 * This blocks until the sensor has completed a reading 00060 * 00061 *@returns The temperature in degrees celsius 00062 */ 00063 float readTemperature(); 00064 00065 00066 00067 private: 00068 /** 00069 * Method which blocks until the sensor is ready to be read. 00070 * @returns 1 when successful. 00071 */ 00072 int _waitReady(); 00073 //Interfaces 00074 SPI _spi; 00075 DigitalOut _CSB; 00076 00077 //Pins that woudl be required to use SCP1000 in different modes 00078 // DigitalIn _DRDY; //Interrupt data ready - also need to be able to attach a function to this class 00079 // DigitalOut _TRIG; //Trigger 00080 // DigitalOut _PD; //Power Down 00081 00082 00083 }; 00084 #endif
Generated on Wed Jul 13 2022 01:56:31 by 1.7.2