Venkata Siva Krishna Madala / ENS160_Library

Dependents:   ECE4180FinalProjectFall22

Committer:
krishnamvs
Date:
Tue Dec 06 21:21:28 2022 +0000
Revision:
3:63ff52373e71
Child:
4:cb50c2f7e2b2
V1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
krishnamvs 3:63ff52373e71 1 #include "ens160_i2c_regs.h"
krishnamvs 3:63ff52373e71 2
krishnamvs 3:63ff52373e71 3 #define ENS160_ADDRESS_LOW 0x52
krishnamvs 3:63ff52373e71 4 #define ENS160_ADDRESS_HIGH 0x53
krishnamvs 3:63ff52373e71 5
krishnamvs 3:63ff52373e71 6 #define ENS160_DEVICE_ID 0x0160
krishnamvs 3:63ff52373e71 7
krishnamvs 3:63ff52373e71 8 class ENS160 {
krishnamvs 3:63ff52373e71 9 public:
krishnamvs 3:63ff52373e71 10 uint8_t i2c_address;
krishnamvs 3:63ff52373e71 11 I2C i2c;
krishnamvs 3:63ff52373e71 12 ENS160(PinName sda, PinName scl, uint8_t i2c_device_address);
krishnamvs 3:63ff52373e71 13 bool ping(uint8_t address);
krishnamvs 3:63ff52373e71 14
krishnamvs 3:63ff52373e71 15 ///////////////////////////////////////////////////////////////////////
krishnamvs 3:63ff52373e71 16 // init()
krishnamvs 3:63ff52373e71 17 // Called to init the system. Connects to the device and sets it up for
krishnamvs 3:63ff52373e71 18 // operation
krishnamvs 3:63ff52373e71 19
krishnamvs 3:63ff52373e71 20 bool init();
krishnamvs 3:63ff52373e71 21
krishnamvs 3:63ff52373e71 22 ///////////////////////////////////////////////////////////////////////
krishnamvs 3:63ff52373e71 23 // isConnected()
krishnamvs 3:63ff52373e71 24 // Parameter Description
krishnamvs 3:63ff52373e71 25 // --------- -----------------------------
krishnamvs 3:63ff52373e71 26 // retval true if device is connected, false if not connected
krishnamvs 3:63ff52373e71 27
krishnamvs 3:63ff52373e71 28 bool isConnected(); // Checks if sensor ack's the I2C request
krishnamvs 3:63ff52373e71 29
krishnamvs 3:63ff52373e71 30 //////////////////////////////////////////////////////////////////////////////////
krishnamvs 3:63ff52373e71 31 // writeRegisterRegion()
krishnamvs 3:63ff52373e71 32 // Parameter Description
krishnamvs 3:63ff52373e71 33 // --------- -----------------------------
krishnamvs 3:63ff52373e71 34 // reg register to write to
krishnamvs 3:63ff52373e71 35 // data Array to store data in
krishnamvs 3:63ff52373e71 36 // length Length of the data being written in bytes
krishnamvs 3:63ff52373e71 37 // retval -1 = error, 0 = success
krishnamvs 3:63ff52373e71 38
krishnamvs 3:63ff52373e71 39 int32_t writeRegisterRegion(uint8_t *data, uint8_t length);
krishnamvs 3:63ff52373e71 40 int32_t writeRegisterRegion(uint8_t reg, uint8_t data);
krishnamvs 3:63ff52373e71 41
krishnamvs 3:63ff52373e71 42 //////////////////////////////////////////////////////////////////////////////////
krishnamvs 3:63ff52373e71 43 // readRegisterRegion()
krishnamvs 3:63ff52373e71 44 // Parameter Description
krishnamvs 3:63ff52373e71 45 // --------- -----------------------------
krishnamvs 3:63ff52373e71 46 // reg register to read from
krishnamvs 3:63ff52373e71 47 // data Array to store data in
krishnamvs 3:63ff52373e71 48 // length Length of the data to read in bytes
krishnamvs 3:63ff52373e71 49 // retval -1 = error, 0 = success
krishnamvs 3:63ff52373e71 50
krishnamvs 3:63ff52373e71 51 uint8_t readRegisterRegion(uint8_t reg, uint8_t *data, uint8_t length);
krishnamvs 3:63ff52373e71 52
krishnamvs 3:63ff52373e71 53 //////////////////////////////////////////////////////////////////////////////////
krishnamvs 3:63ff52373e71 54 // General Operation
krishnamvs 3:63ff52373e71 55 bool setOperatingMode(uint8_t);
krishnamvs 3:63ff52373e71 56 int8_t getOperatingMode();
krishnamvs 3:63ff52373e71 57 uint32_t getAppVer();
krishnamvs 3:63ff52373e71 58 uint16_t getUniqueID();
krishnamvs 3:63ff52373e71 59
krishnamvs 3:63ff52373e71 60 //////////////////////////////////////////////////////////////////////////////////
krishnamvs 3:63ff52373e71 61 // Interrupts
krishnamvs 3:63ff52373e71 62 bool configureInterrupt(uint8_t);
krishnamvs 3:63ff52373e71 63 bool enableInterrupt(bool enable = true);
krishnamvs 3:63ff52373e71 64 bool setInterruptPolarity(bool activeHigh = true);
krishnamvs 3:63ff52373e71 65 int8_t getInterruptPolarity();
krishnamvs 3:63ff52373e71 66 bool setInterruptDrive(bool pushPull = true);
krishnamvs 3:63ff52373e71 67 bool setDataInterrupt(bool enable = true);
krishnamvs 3:63ff52373e71 68 bool setGPRInterrupt(bool);
krishnamvs 3:63ff52373e71 69
krishnamvs 3:63ff52373e71 70 //////////////////////////////////////////////////////////////////////////////////
krishnamvs 3:63ff52373e71 71 // Temperature and Humidity compensation
krishnamvs 3:63ff52373e71 72 bool setTempCompensation(float);
krishnamvs 3:63ff52373e71 73 float getTempCompensation();
krishnamvs 3:63ff52373e71 74 bool setTempCompensationCelsius(float);
krishnamvs 3:63ff52373e71 75 float getTempCompensationCelsius();
krishnamvs 3:63ff52373e71 76 bool setRHCompensation(uint16_t);
krishnamvs 3:63ff52373e71 77 bool setRHCompensationFloat(float);
krishnamvs 3:63ff52373e71 78
krishnamvs 3:63ff52373e71 79 //////////////////////////////////////////////////////////////////////////////////
krishnamvs 3:63ff52373e71 80 bool checkDataStatus();
krishnamvs 3:63ff52373e71 81 bool checkGPRStatus();
krishnamvs 3:63ff52373e71 82 uint8_t getFlags();
krishnamvs 3:63ff52373e71 83 bool checkOperationStatus();
krishnamvs 3:63ff52373e71 84 bool getOperationError();
krishnamvs 3:63ff52373e71 85
krishnamvs 3:63ff52373e71 86 //////////////////////////////////////////////////////////////////////////////////
krishnamvs 3:63ff52373e71 87 // Data registers
krishnamvs 3:63ff52373e71 88 uint8_t getAQI();
krishnamvs 3:63ff52373e71 89 uint16_t getTVOC();
krishnamvs 3:63ff52373e71 90 uint16_t getETOH();
krishnamvs 3:63ff52373e71 91 uint16_t getECO2();
krishnamvs 3:63ff52373e71 92 float getTempKelvin();
krishnamvs 3:63ff52373e71 93 float getTempCelsius();
krishnamvs 3:63ff52373e71 94 float getRH();
krishnamvs 3:63ff52373e71 95 };