Dependents:   V2_GPSRTC

Committer:
joosttromp
Date:
Fri Jun 17 12:37:27 2011 +0000
Revision:
0:55ea30b5de1e

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joosttromp 0:55ea30b5de1e 1 /**
joosttromp 0:55ea30b5de1e 2 * @section LICENSE
joosttromp 0:55ea30b5de1e 3 * This program is free software; you can redistribute it and/or modify
joosttromp 0:55ea30b5de1e 4 * it under the terms of the GNU General Public License as published by
joosttromp 0:55ea30b5de1e 5 * the Free Software Foundation; either version 2 of the License, or
joosttromp 0:55ea30b5de1e 6 * (at your option) any later version.
joosttromp 0:55ea30b5de1e 7 *
joosttromp 0:55ea30b5de1e 8 * This program is distributed in the hope that it will be useful, but
joosttromp 0:55ea30b5de1e 9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
joosttromp 0:55ea30b5de1e 10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
joosttromp 0:55ea30b5de1e 11 * for more details.
joosttromp 0:55ea30b5de1e 12 *
joosttromp 0:55ea30b5de1e 13 * You should have received a copy of the GNU General Public License along
joosttromp 0:55ea30b5de1e 14 * with this program; if not, write to the Free Software Foundation, Inc.,
joosttromp 0:55ea30b5de1e 15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
joosttromp 0:55ea30b5de1e 16 *
joosttromp 0:55ea30b5de1e 17 * @section DESCRIPTION
joosttromp 0:55ea30b5de1e 18 * Library to interface with the SCP1000 pressure and temperature sensor.
joosttromp 0:55ea30b5de1e 19 */
joosttromp 0:55ea30b5de1e 20
joosttromp 0:55ea30b5de1e 21 #ifndef _SCP1000_H
joosttromp 0:55ea30b5de1e 22 #define _SCP1000_H
joosttromp 0:55ea30b5de1e 23
joosttromp 0:55ea30b5de1e 24 #include "mbed.h"
joosttromp 0:55ea30b5de1e 25
joosttromp 0:55ea30b5de1e 26 /**
joosttromp 0:55ea30b5de1e 27 * Class to interface with the SCP1000 pressure and temperature sensor.
joosttromp 0:55ea30b5de1e 28 */
joosttromp 0:55ea30b5de1e 29 class SCP1000 {
joosttromp 0:55ea30b5de1e 30 public:
joosttromp 0:55ea30b5de1e 31 /**
joosttromp 0:55ea30b5de1e 32 * Constructor.
joosttromp 0:55ea30b5de1e 33 *
joosttromp 0:55ea30b5de1e 34 * @param mosi SPI MOSI pin
joosttromp 0:55ea30b5de1e 35 * @param miso SPI MISO pin
joosttromp 0:55ea30b5de1e 36 * @param sclk SPI SCLK pin
joosttromp 0:55ea30b5de1e 37 * @param cs Chip select pin
joosttromp 0:55ea30b5de1e 38 */
joosttromp 0:55ea30b5de1e 39 SCP1000(PinName mosi, PinName miso, PinName sclk, PinName cs);
joosttromp 0:55ea30b5de1e 40
joosttromp 0:55ea30b5de1e 41 ~SCP1000() { /* empty */ };
joosttromp 0:55ea30b5de1e 42
joosttromp 0:55ea30b5de1e 43 /**
joosttromp 0:55ea30b5de1e 44 * Read the pressure.
joosttromp 0:55ea30b5de1e 45 *
joosttromp 0:55ea30b5de1e 46 * @returns The pressure in pascals.
joosttromp 0:55ea30b5de1e 47 */
joosttromp 0:55ea30b5de1e 48 unsigned long readPressure();
joosttromp 0:55ea30b5de1e 49
joosttromp 0:55ea30b5de1e 50 /**
joosttromp 0:55ea30b5de1e 51 * Read the temperature.
joosttromp 0:55ea30b5de1e 52 *
joosttromp 0:55ea30b5de1e 53 * @returns The temperature in Celsius.
joosttromp 0:55ea30b5de1e 54 */
joosttromp 0:55ea30b5de1e 55 float readTemperature();
joosttromp 0:55ea30b5de1e 56
joosttromp 0:55ea30b5de1e 57
joosttromp 0:55ea30b5de1e 58 private:
joosttromp 0:55ea30b5de1e 59 static const char PRESSURE = 0x1F; //Pressure 3 MSB
joosttromp 0:55ea30b5de1e 60 static const char PRESSURE_LSB = 0x20; //Pressure 16 LSB
joosttromp 0:55ea30b5de1e 61 static const char TEMP = 0x21; //16 bit temp
joosttromp 0:55ea30b5de1e 62 SPI m_spi;
joosttromp 0:55ea30b5de1e 63 DigitalOut m_cs;
joosttromp 0:55ea30b5de1e 64
joosttromp 0:55ea30b5de1e 65 char read_register(char register_name);
joosttromp 0:55ea30b5de1e 66 void write_register(char register_name, char register_value);
joosttromp 0:55ea30b5de1e 67 float read_register16(char register_name);
joosttromp 0:55ea30b5de1e 68
joosttromp 0:55ea30b5de1e 69 };
joosttromp 0:55ea30b5de1e 70
joosttromp 0:55ea30b5de1e 71 #endif // _SCP1000_H