A library to use Honeywell pressure sensors from HSC series with SPI connection. For calibration scale and pressure range you have to set the declarations inside the hsc_spi.h file - Default values are for 10-90% calibration and 1.6bar absolute sensor
hsc_spi.h@0:0056857990b9, 2014-02-16 (annotated)
- Committer:
- brunoalfano
- Date:
- Sun Feb 16 18:30:04 2014 +0000
- Revision:
- 0:0056857990b9
Library for Honeywell HSC pressure sensor via SPI
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
brunoalfano | 0:0056857990b9 | 1 | #ifndef hsc_spi_h |
brunoalfano | 0:0056857990b9 | 2 | #define hsc_spi_h |
brunoalfano | 0:0056857990b9 | 3 | |
brunoalfano | 0:0056857990b9 | 4 | #include "mbed.h" |
brunoalfano | 0:0056857990b9 | 5 | |
brunoalfano | 0:0056857990b9 | 6 | #define OUTPUT_MAX 0x399A |
brunoalfano | 0:0056857990b9 | 7 | #define OUTPUT_MIN 0x0666 |
brunoalfano | 0:0056857990b9 | 8 | #define P_MAX 1600 |
brunoalfano | 0:0056857990b9 | 9 | #define P_MIN 0 |
brunoalfano | 0:0056857990b9 | 10 | |
brunoalfano | 0:0056857990b9 | 11 | class hsc_spi |
brunoalfano | 0:0056857990b9 | 12 | { |
brunoalfano | 0:0056857990b9 | 13 | SPI& spi; |
brunoalfano | 0:0056857990b9 | 14 | DigitalOut ncs; |
brunoalfano | 0:0056857990b9 | 15 | Timer pollTimer; |
brunoalfano | 0:0056857990b9 | 16 | public: |
brunoalfano | 0:0056857990b9 | 17 | |
brunoalfano | 0:0056857990b9 | 18 | hsc_spi(SPI& _spi, PinName _ncs); |
brunoalfano | 0:0056857990b9 | 19 | //void initialise(int out_max,int out_min,int pmax, int pmin); |
brunoalfano | 0:0056857990b9 | 20 | float read_press(); |
brunoalfano | 0:0056857990b9 | 21 | float read_temp(); |
brunoalfano | 0:0056857990b9 | 22 | void spi_init(); |
brunoalfano | 0:0056857990b9 | 23 | void select(); |
brunoalfano | 0:0056857990b9 | 24 | void deselect(); |
brunoalfano | 0:0056857990b9 | 25 | |
brunoalfano | 0:0056857990b9 | 26 | private: |
brunoalfano | 0:0056857990b9 | 27 | PinName _CS_pin; |
brunoalfano | 0:0056857990b9 | 28 | PinName _SO_pin; |
brunoalfano | 0:0056857990b9 | 29 | PinName _SCK_pin; |
brunoalfano | 0:0056857990b9 | 30 | float _error; |
brunoalfano | 0:0056857990b9 | 31 | }; |
brunoalfano | 0:0056857990b9 | 32 | |
brunoalfano | 0:0056857990b9 | 33 | #endif |