Library to interface the SCP1000 temperature and pressure sensor.

Dependents:   SCP1000_Example ku-make_sensor ku-make_sensor201302 SCP1000_Example ... more

Committer:
kadams6
Date:
Fri Oct 08 17:41:11 2010 +0000
Revision:
8:1049590388b6
Parent:
7:61d2e698d988
Child:
9:47d6f205890b

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kadams6 8:1049590388b6 1 /**
kadams6 8:1049590388b6 2 * SCP1000 header file
kadams6 8:1049590388b6 3 */
kadams6 3:4d8b8ca54451 4
kadams6 0:0b8b5828e1a3 5 #ifndef _SCP1000_H
kadams6 0:0b8b5828e1a3 6 #define _SCP1000_H
kadams6 0:0b8b5828e1a3 7
kadams6 0:0b8b5828e1a3 8 #include "mbed.h"
kadams6 0:0b8b5828e1a3 9
kadams6 8:1049590388b6 10 /**
kadams6 8:1049590388b6 11 * Class to interface with the SCP1000 pressure and temperature sensor.
kadams6 8:1049590388b6 12 */
kadams6 0:0b8b5828e1a3 13 class SCP1000 {
kadams6 0:0b8b5828e1a3 14 public:
kadams6 7:61d2e698d988 15 /**
kadams6 7:61d2e698d988 16 * Constructor.
kadams6 7:61d2e698d988 17 *
kadams6 7:61d2e698d988 18 * @param mosi SPI MOSI pin
kadams6 7:61d2e698d988 19 * @param miso SPI MISO pin
kadams6 7:61d2e698d988 20 * @param sclk SPI SCLK pin
kadams6 7:61d2e698d988 21 * @param cs Chip select pin
kadams6 7:61d2e698d988 22 */
kadams6 4:295e118b6e85 23 SCP1000(PinName mosi, PinName miso, PinName sclk, PinName cs);
kadams6 0:0b8b5828e1a3 24
kadams6 0:0b8b5828e1a3 25 ~SCP1000() { /* empty */ };
kadams6 0:0b8b5828e1a3 26
kadams6 1:5fcf1fe4a161 27 /**
kadams6 7:61d2e698d988 28 * Read the pressure.
kadams6 7:61d2e698d988 29 *
kadams6 7:61d2e698d988 30 * @returns The pressure in pascals.
kadams6 7:61d2e698d988 31 */
kadams6 4:295e118b6e85 32 unsigned long readPressure();
kadams6 0:0b8b5828e1a3 33
kadams6 7:61d2e698d988 34 /**
kadams6 7:61d2e698d988 35 * Read the temperature.
kadams6 7:61d2e698d988 36 *
kadams6 7:61d2e698d988 37 * @returns The temperature in Celsius.
kadams6 7:61d2e698d988 38 */
kadams6 4:295e118b6e85 39 float readTemperature();
kadams6 0:0b8b5828e1a3 40
kadams6 0:0b8b5828e1a3 41
kadams6 0:0b8b5828e1a3 42 private:
kadams6 0:0b8b5828e1a3 43 static const char PRESSURE = 0x1F; //Pressure 3 MSB
kadams6 0:0b8b5828e1a3 44 static const char PRESSURE_LSB = 0x20; //Pressure 16 LSB
kadams6 0:0b8b5828e1a3 45 static const char TEMP = 0x21; //16 bit temp
kadams6 0:0b8b5828e1a3 46 SPI m_spi;
kadams6 0:0b8b5828e1a3 47 DigitalOut m_cs;
kadams6 0:0b8b5828e1a3 48
kadams6 4:295e118b6e85 49 char read_register(char register_name);
kadams6 4:295e118b6e85 50 void write_register(char register_name, char register_value);
kadams6 4:295e118b6e85 51 float read_register16(char register_name);
kadams6 0:0b8b5828e1a3 52
kadams6 0:0b8b5828e1a3 53 };
kadams6 0:0b8b5828e1a3 54
kadams6 0:0b8b5828e1a3 55 #endif // _SCP1000_H