Mbed library for SPS30 i2c communication (Configured to be interfaced with TresidderOS) Inherits members and methods from SensorDriver class
Diff: sps30.h
- Revision:
- 9:a5fe43e183e2
- Parent:
- 8:f6b216228067
- Child:
- 10:228c926a2416
--- a/sps30.h Fri Mar 15 06:52:32 2019 +0000 +++ b/sps30.h Wed Mar 27 06:04:36 2019 +0000 @@ -4,6 +4,7 @@ * Contributor(s): * Yap Zi Qi yap_zi_qi@tech.gov.sg *******************************************************************************/ +#include "src/SensorDriver/sensor_driver.h" #ifndef SPS30_H #define SPS30_H @@ -38,42 +39,16 @@ #define I2C_FREQUENCY_STD 100000 // SPS30 uses 100MHz for I2C communication /** Create SPS30 controller class + * @brief inherits SensorDriver members and methods essential for Sensor Thread * * @param sps30 class * */ -class Sps30 { +class Sps30: public SensorDriver { public: - enum SPSStatus { - DISCONNECTED, - CONNECTED, - DATANOTREADY, - DATAREADY, - DATAERROR, - DATAOOR, - DATAOK, - } SPSStatus; - uint16_t sps_ready; /**< 1 = ready, 0 = busy */ uint32_t clean_interval_i; /** 32 unsigned bit in seconds */ - - float mass_1p0_f; /**< float of Mass Conc of PM1.0 */ - float mass_2p5_f; /**< float of Mass Conc of PM2.5 */ - float mass_4p0_f; /**< float of Mass Conc of PM4.0 */ - float mass_10p0_f; /**< float of Mass Conc of PM10 */ - - float num_0p5_f; /**< float of Number Conc of PM0.5 */ - float num_1p0_f; /**< float of Number Conc of PM1.0 */ - float num_2p5_f; /**< float of Number Conc of PM2.5 */ - float num_4p0_f; /**< float of Number Conc of PM4.0 */ - float num_10p0_f; /**< float of Number Conc of PM10 */ - - float typ_pm_size_f; /**< float of Typical Particle Size */ - - uint8_t sn[33]; /**< ASCII Serial Number */ - - /** Create a SPS30 object using the specified I2C object * @param sda - mbed I2C interface pin @@ -99,7 +74,7 @@ * * @return enum SPSStatus */ - uint8_t InitSPS30(); + void InitSensor(); /** Poll SPS30 Data * @@ -107,8 +82,7 @@ * * @return enum SPSStatus */ - uint8_t PollSPS30(); - + int PollSensor(); private: @@ -120,6 +94,11 @@ }; char i2cbuff[60]; + + uint8_t sn[33]; /**< ASCII Serial Number */ + + std::vector<float> sensor_float_data; /** Vector of sensor float data **/ + std::vector<std::string> sensor_data_name; /** Private list of sensor data types **/ uint16_t clean_interval_m; /**< High order 16 bit word of Auto Clean Interval */ uint16_t clean_interval_l; /**< High order 16 bit word of Auto Clean Interval */ @@ -160,6 +139,19 @@ uint32_t typ_pm_size_i; /**< 32 bit int of Typical Particle Size */ + float mass_1p0_f; /**< float of Mass Conc of PM1.0 */ + float mass_2p5_f; /**< float of Mass Conc of PM2.5 */ + float mass_4p0_f; /**< float of Mass Conc of PM4.0 */ + float mass_10p0_f; /**< float of Mass Conc of PM10 */ + + float num_0p5_f; /**< float of Number Conc of PM0.5 */ + float num_1p0_f; /**< float of Number Conc of PM1.0 */ + float num_2p5_f; /**< float of Number Conc of PM2.5 */ + float num_4p0_f; /**< float of Number Conc of PM4.0 */ + float num_10p0_f; /**< float of Number Conc of PM10 */ + + float typ_pm_size_f; /**< float of Typical Particle Size */ + /** Start Auto-Measurement * * @param --none-- @@ -176,6 +168,15 @@ */ uint8_t StopMeasurement(); + /** Get Serial Number + * + * @param --none-- + * @see ASCII Serial Number as sn[33] + * + * @return enum SPSerror + */ + int GetSerialNumber(); + /** Get Ready Status register * * @param --none-- @@ -194,6 +195,7 @@ */ uint8_t ReadMeasurement(); + /** Calculate the SPS30 CRC value * * @param 16 bit value to perform a CRC check on @@ -210,15 +212,7 @@ * @return enum SPSerror */ uint8_t CheckCrc2b(uint16_t seed, uint8_t crc_in); - - /** Get Serial Number - * - * @param --none-- - * @see ASCII Serial Number as sn[33] - * - * @return enum SPSerror - */ - uint8_t GetSerialNumber(); + /** Read Auto Cleaning Interval on the SPS30 * @@ -254,6 +248,15 @@ * @return enum SPSerror */ uint8_t SoftReset(); + + /** Create a Sensor Data Array to be read from Sensor Thread + * + * @param --none-- + * @see sensor_data vector pair in SensorDriver + * + * @return none + */ + void GetDataArray(); protected: I2C _i2c;