Library to interface the SCP1000 temperature and pressure sensor.

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

SCP1000.h

Committer:
kadams6
Date:
2010-10-08
Revision:
8:1049590388b6
Parent:
7:61d2e698d988
Child:
9:47d6f205890b

File content as of revision 8:1049590388b6:

/**
 * SCP1000 header file
 */

#ifndef _SCP1000_H
#define _SCP1000_H

#include "mbed.h"

/**
 * Class to interface with the SCP1000 pressure and temperature sensor.
 */
class SCP1000 {
    public:
        /**
         * Constructor.
         *
         * @param mosi SPI MOSI pin
         * @param miso SPI MISO pin
         * @param sclk SPI SCLK pin
         * @param cs Chip select pin
         */
        SCP1000(PinName mosi, PinName miso, PinName sclk, PinName cs);
        
        ~SCP1000() { /* empty */ };
        
        /**
         * Read the pressure.
         *
         * @returns The pressure in pascals.
         */
        unsigned long readPressure();
        
        /**
         * Read the temperature.
         *
         * @returns The temperature in Celsius.
         */
        float readTemperature();
        
        
    private:
        static const char PRESSURE = 0x1F;   //Pressure 3 MSB
        static const char PRESSURE_LSB = 0x20; //Pressure 16 LSB
        static const char TEMP = 0x21;       //16 bit temp
        SPI m_spi;
        DigitalOut m_cs;
        
        char read_register(char register_name);
        void write_register(char register_name, char register_value);
        float read_register16(char register_name);

};

#endif // _SCP1000_H