Steve Martin / libdev_si7021

si7021.h

Committer:
ninensei
Date:
2017-09-12
Revision:
0:9909c9c7d326

File content as of revision 0:9909c9c7d326:

#include "mbed.h"

#ifndef SI7021_H
#define SI7021_H

typedef struct {
    float       temp_C;
    float       humidity_PR;
//    int16_t     temp;
//    int16_t     temp_norm;
//    int16_t     humidity;
//    int16_t     humidity_norm;
} si7021_measurements_t;

class SI7021 {
 public:
    /**
    * Constructor
    *
    * @param i2c I2C class servicing the strip
    */
    SI7021(I2C * i2c) : _i2c(i2c) {}

    /**
    * Read temperature and humidity
    *
    * @param data points to struct to store measurements in.  Stucture is
    *      valid only when function returns success indication.
    *
    * @returns true (success) or false (failure)
    */
    bool read(si7021_measurements_t * data);

 protected:
 
    /**
    * I2C read/write helper function
    *
    * @param address is the register to read/write
    * @param buff holds the data to write and recieves the data to read
    * @param writeSize is the number of bytes to write to register
    * @param readSize is the number of bytes to retrieve from device
    *
    * @returns true (success) or false (failure)
    */
    bool _i2c_transfer(int address, void * buff, size_t writeSize, size_t readSize);
    
    /**
    * 
    bool _validate(void)
    */

    I2C *_i2c;
};

#endif //SI7021_H