Low voltage digital temperature sensor
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: X_NUCLEO_IKS01A3 X_NUCLEO_IKS01A3 X_NUCLEO_IKS01A3
Diff: STTS751Sensor.h
- Revision:
- 1:5859badee052
- Parent:
- 0:128dae13c732
--- a/STTS751Sensor.h Wed Mar 06 10:18:41 2019 +0000 +++ b/STTS751Sensor.h Wed Jul 24 14:20:10 2019 +0000 @@ -52,15 +52,14 @@ /* Defines -------------------------------------------------------------------*/ /* Typedefs ------------------------------------------------------------------*/ /* Class Declaration ---------------------------------------------------------*/ - + /** * Abstract class of a STTS751 temperature sensor. */ -class STTS751Sensor : public TempSensor -{ - public: - - STTS751Sensor(DevI2C *i2c, uint8_t address=STTS751_0xxxx_ADD_7K5, PinName int_pin=NC); +class STTS751Sensor : public TempSensor { +public: + + STTS751Sensor(DevI2C *i2c, uint8_t address = STTS751_0xxxx_ADD_7K5, PinName int_pin = NC); virtual int init(void *init); virtual int read_id(uint8_t *id); virtual int get_temperature(float *value); @@ -97,7 +96,7 @@ { _int_irq.enable_irq(); } - + /** * @brief Disabling the INT interrupt handling. * @param None. @@ -116,12 +115,14 @@ * @param NumByteToRead: number of bytes to be read. * @retval 0 if ok, an error code otherwise. */ - uint8_t io_read(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead) - { - if (_dev_i2c) return (uint8_t) _dev_i2c->i2c_read(pBuffer, _address, RegisterAddr, NumByteToRead); + uint8_t io_read(uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead) + { + if (_dev_i2c) { + return (uint8_t) _dev_i2c->i2c_read(pBuffer, _address, RegisterAddr, NumByteToRead); + } return 1; } - + /** * @brief Utility function to write data. * @param pBuffer: pointer to data to be written. @@ -129,34 +130,36 @@ * @param NumByteToWrite: number of bytes to write. * @retval 0 if ok, an error code otherwise. */ - uint8_t io_write(uint8_t* pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite) + uint8_t io_write(uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite) { - if (_dev_i2c) return (uint8_t) _dev_i2c->i2c_write(pBuffer, _address, RegisterAddr, NumByteToWrite); + if (_dev_i2c) { + return (uint8_t) _dev_i2c->i2c_write(pBuffer, _address, RegisterAddr, NumByteToWrite); + } return 1; } - private: +private: /* Helper classes. */ DevI2C *_dev_i2c; - + /* Configuration */ uint8_t _address; - InterruptIn _int_irq; - + InterruptIn _int_irq; + uint8_t _is_enabled; float _last_odr; - + stts751_ctx_t _reg_ctx; }; #ifdef __cplusplus - extern "C" { +extern "C" { #endif -int32_t STTS751_io_write( void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite ); -int32_t STTS751_io_read( void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead ); +int32_t STTS751_io_write(void *handle, uint8_t WriteAddr, uint8_t *pBuffer, uint16_t nBytesToWrite); +int32_t STTS751_io_read(void *handle, uint8_t ReadAddr, uint8_t *pBuffer, uint16_t nBytesToRead); #ifdef __cplusplus - } +} #endif #endif