Maxim Integrated MAX30205 C, C++ source code driver software: MAX30205 is accurate to +-0.1°C over the range of 37.0°C to 39.0°C. One-shot, shutdown modes are available for reduced power usage. Thermostat thresholds allow for temperature hysteresis or for alarm settings. The MAX30205 is available in a compact 3x3 mm, 8-pin TDFN package. Operating supply voltage range is 2.7V to 3.3V. Typical applications are for clinical digital thermometers, thermostats with hysteresis, and temperature alarms.
Dependents: MAX30205_Human_Body_Temperature_Sensor
Diff: MAX30205.h
- Revision:
- 1:d4271ef9f37f
- Parent:
- 0:cdad7a9ef486
- Child:
- 3:939090042b32
diff -r cdad7a9ef486 -r d4271ef9f37f MAX30205.h
--- a/MAX30205.h Mon Apr 03 23:11:58 2017 +0000
+++ b/MAX30205.h Thu Apr 06 00:05:03 2017 +0000
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
+ * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -64,6 +64,22 @@
THYST = 0x02,
TOS = 0x03
};
+
+ ///MAX30205 Configuration register bitfields
+ union Config
+ {
+ uint8_t all;
+ struct BitField
+ {
+ uint8_t shutdown : 1;
+ uint8_t comp_int : 1;
+ uint8_t os_polarity : 1;
+ uint8_t fault_queue : 2;
+ uint8_t data_format : 1;
+ uint8_t timeout : 1;
+ uint8_t one_shot : 1;
+ }bits;
+ };
/**
* @brief Constructor using I2C PinNames
@@ -71,69 +87,66 @@
* @param scl - Pinname for scl
* @param slaveAddress - 7-bit I2C address
*/
- MAX30205(PinName sda, PinName scl, uint8_t slaveAddress);
+ MAX30205(PinName sda, PinName scl, uint8_t slaveAddress, PinName os = NC);
/**
* @brief Constructor using reference to I2C object
* @param i2c - Reference to I2C object
* @param slaveAddress - 7-bit I2C address
*/
- MAX30205(I2C& i2c, uint8_t slaveAddress);
+ MAX30205(I2C &i2c, uint8_t slaveAddress, PinName os = NC);
/** @brief Destructor */
~MAX30205(void);
- /** @brief Write register of device at slave address
- * @param reg - Register address
- * @param value - Value to write
- * @return 0 on success, non-zero on failure
- */
- int32_t reg_write(Registers reg, uint8_t value);
-
- /**
- * @brief Read register of device at slave address
- * @param reg - Register address
- * @param[out] value - Read data on success
- * @return 0 on success, non-zero on failure
- */
- int32_t reg_read(Registers reg, uint8_t& value);
-
- /**
- * @brief Write a 16-bit value into device at slave address
- * @param reg - Register address
- * @param value - 16-bit value to write
- * @return 0 on success, non-zero on failure
- */
- int32_t reg_write16(Registers reg, uint16_t value);
-
- /**
- * @brief Read a 16-bit value from a device at a slave address
- * @param reg - Register address
- * @param[out] value - Read data on success
- * @return 0 on success, non-zero on failure
- */
- int32_t reg_read16(Registers reg, uint16_t& value);
-
/**
* @brief Read the temperature from the device into a 16 bit value
* @param[out] value - Raw temperature data on success
* @return 0 on success, non-zero on failure
*/
- int32_t readTemperature(uint16_t& value);
+ int32_t readTemperature(uint16_t &value);
+
+ /**
+ * @brief Read the configuration register
+ * @param config - Reference to Configuration type
+ * @return 0 on success, non-zero on failure
+ */
+ int32_t readConfiguration(Config &config);
+
+ /**
+ * @brief Write the configuration register with given configuration
+ * @param config - Configuration to write
+ * @return 0 on success, non-zero on failure
+ */
+ int32_t writeConfiguration(const Config config);
/**
* @brief Read the THYST value from a specified device instance
* @param[out] value - THYST register value on success
* @return 0 on success, non-zero on failure
*/
- int32_t reg_THYST_Read(uint16_t& value);
+ int32_t readTHYST(uint16_t &value);
/**
* @brief Write the THYST to a device instance
* @param value - 16-bit value to write
* @return 0 on success, non-zero on failure
*/
- int32_t reg_THYST_Write(uint16_t value);
+ int32_t writeTHYST(const uint16_t value);
+
+ /**
+ * @brief Read the TOS value from device
+ * @param[out] value - TOS register value on success
+ * @return 0 on success, non-zero on failure
+ */
+ int32_t readTOS(uint16_t &value);
+
+ /**
+ * @brief Write the TOS register
+ * @param value - 16-bit value to write
+ * @return 0 on success, non-zero on failure
+ */
+ int32_t writeTOS(const uint16_t value);
/**
* @brief Convert a raw temperature value into a float
@@ -148,12 +161,32 @@
* @returns Returns the converted Fahrenheit value
*/
float toFahrenheit(float temperatureC);
+
+protected:
+
+ /**
+ * @brief Write register of device at slave address
+ * @param reg - Register address
+ * @param value - Value to write
+ * @return 0 on success, non-zero on failure
+ */
+ int32_t writeRegister(Registers reg, uint16_t value);
+
+ /**
+ * @brief Read register of device at slave address
+ * @param reg - Register address
+ * @param[out] value - Read data on success
+ * @return 0 on success, non-zero on failure
+ */
+ int32_t readRegister(Registers reg, uint16_t &value);
private:
/// I2C object
I2C m_i2c;
/// Device slave address
uint8_t m_writeAddress, m_readAddress;
+ /// Over temperature shutdown interrupt pin
+ DigitalIn m_os;
};
#endif /* __MAX30205_H_ */