loragw_stts751.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. / _____) _ | |
  3. ( (____ _____ ____ _| |_ _____ ____| |__
  4. \____ \| ___ | (_ _) ___ |/ ___) _ \
  5. _____) ) ____| | | || |_| ____( (___| | | |
  6. (______/|_____)_|_|_| \__)_____)\____)_| |_|
  7. (C)2019 Semtech
  8. Description:
  9. Basic driver for ST ts751 temperature sensor
  10. License: Revised BSD License, see LICENSE.TXT file include in the project
  11. */
  12. #ifndef _LORAGW_STTS751_H
  13. #define _LORAGW_STTS751_H
  14. /* -------------------------------------------------------------------------- */
  15. /* --- DEPENDANCIES --------------------------------------------------------- */
  16. #include <stdint.h> /* C99 types */
  17. #include <stdbool.h> /* bool type */
  18. #include "config.h" /* library configuration options (dynamically generated) */
  19. /* -------------------------------------------------------------------------- */
  20. /* --- INTERNAL SHARED TYPES ------------------------------------------------ */
  21. /* -------------------------------------------------------------------------- */
  22. /* --- INTERNAL SHARED FUNCTIONS -------------------------------------------- */
  23. /* -------------------------------------------------------------------------- */
  24. /* --- PUBLIC CONSTANTS ----------------------------------------------------- */
  25. /*
  26. 0x39: STTS751-0DP3F
  27. 0x3B: STTS751-1DP3F
  28. 0x38: STTS751-0DP3F on full duplex CN490 ref design
  29. */
  30. static const uint8_t I2C_PORT_TEMP_SENSOR[] = {0x39, 0x3B, 0x38};
  31. /* -------------------------------------------------------------------------- */
  32. /* --- PUBLIC FUNCTIONS ----------------------------------------------------- */
  33. /**
  34. @brief Configure the temperature sensor (ST TS751)
  35. @param i2c_fd file descriptor to access the sensor through I2C
  36. @param i2c_addr the I2C device address of the sensor
  37. @return LGW_I2C_ERROR if fails, LGW_I2C_SUCCESS otherwise
  38. */
  39. int stts751_configure(int i2c_fd, uint8_t i2c_addr);
  40. /**
  41. @brief Get the temperature from the sensor
  42. @param i2c_fd file descriptor to access the sensor through I2C
  43. @param i2c_addr the I2C device address of the sensor
  44. @param temperature pointer to store the temerature read from sensor
  45. @return LGW_I2C_ERROR if fails, LGW_I2C_SUCCESS otherwise
  46. */
  47. int stts751_get_temperature(int i2c_fd, uint8_t i2c_addr, float * temperature);
  48. #endif
  49. /* --- EOF ------------------------------------------------------------------ */