Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SCP1000.h
00001 /** 00002 * @section LICENSE 00003 * This program is free software; you can redistribute it and/or modify 00004 * it under the terms of the GNU General Public License as published by 00005 * the Free Software Foundation; either version 2 of the License, or 00006 * (at your option) any later version. 00007 * 00008 * This program is distributed in the hope that it will be useful, but 00009 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00010 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00011 * for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License along 00014 * with this program; if not, write to the Free Software Foundation, Inc., 00015 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 * 00017 * @section DESCRIPTION 00018 * Library to interface with the SCP1000 pressure and temperature sensor. 00019 */ 00020 00021 #ifndef _SCP1000_H 00022 #define _SCP1000_H 00023 00024 #include "mbed.h" 00025 00026 /** 00027 * Class to interface with the SCP1000 pressure and temperature sensor. 00028 */ 00029 class SCP1000 { 00030 public: 00031 /** 00032 * Constructor. 00033 * 00034 * @param mosi SPI MOSI pin 00035 * @param miso SPI MISO pin 00036 * @param sclk SPI SCLK pin 00037 * @param cs Chip select pin 00038 */ 00039 SCP1000(PinName mosi, PinName miso, PinName sclk, PinName cs); 00040 00041 ~SCP1000() { /* empty */ }; 00042 00043 /** 00044 * Read the pressure. 00045 * 00046 * @returns The pressure in pascals. 00047 */ 00048 unsigned long readPressure(); 00049 00050 /** 00051 * Read the temperature. 00052 * 00053 * @returns The temperature in Celsius. 00054 */ 00055 float readTemperature(); 00056 00057 00058 private: 00059 static const char PRESSURE = 0x1F; //Pressure 3 MSB 00060 static const char PRESSURE_LSB = 0x20; //Pressure 16 LSB 00061 static const char TEMP = 0x21; //16 bit temp 00062 SPI m_spi; 00063 DigitalOut m_cs; 00064 00065 char read_register(char register_name); 00066 void write_register(char register_name, char register_value); 00067 float read_register16(char register_name); 00068 00069 }; 00070 00071 #endif // _SCP1000_H
Generated on Sat Jul 16 2022 15:39:26 by
1.7.2