Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: si7210.h
- Revision:
- 0:ee9d6b55bf85
- Child:
- 1:8cb452601311
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/si7210.h Tue Sep 12 17:17:09 2017 +0000 @@ -0,0 +1,57 @@ +#include "mbed.h" + +#ifndef SI7210_H +#define SI7210_H + +#define SI7210_BASE_ADDR_7BIT 0x30 + +typedef struct { + float mag_T; + float temp_C; +} si7210_measurements_t; + +class SI7210 { + public: + /** + * Constructor + * + * @param i2c I2C class servicing the strip + */ + SI7210(I2C * i2c, uint8_t addr_7bit) : _i2c(i2c) { + _addr_8bit = ((addr_7bit & 0x3) + SI7210_BASE_ADDR_7BIT) << 1; + } + + /** + * 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(si7210_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) + */ + + int _addr_8bit; + I2C *_i2c; +}; + +#endif //SI7210_H