Venkata Siva Krishna Madala / ENS160_Library

Dependents:   ECE4180FinalProjectFall22

Committer:
krishnamvs
Date:
Thu Dec 08 16:39:40 2022 +0000
Revision:
4:cb50c2f7e2b2
Parent:
3:63ff52373e71
Small fixes

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