SHT3X_ATY.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**
  2. * @file SHT3X_ATY.h
  3. *
  4. * @param Project DEVICE_GENERAL_ATY_LIB
  5. *
  6. * @author ATY
  7. *
  8. * @copyright
  9. * - Copyright 2017 - 2025 MZ-ATY
  10. * - This code follows:
  11. * - MZ-ATY Various Contents Joint Statement -
  12. * <a href="https://mengze.top/MZ-ATY_VCJS">
  13. * https://mengze.top/MZ-ATY_VCJS</a>
  14. * - CC 4.0 BY-NC-SA -
  15. * <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  16. * https://creativecommons.org/licenses/by-nc-sa/4.0/</a>
  17. * - Your use will be deemed to have accepted the terms of this statement.
  18. *
  19. * @brief Familiar functions of SHT3X tem&hum transistor for all devices
  20. *
  21. * @version
  22. * - 1_01_200318 > ATY
  23. * -# Preliminary version, first Release
  24. * - 1_02_231229 > ATY
  25. * -# add multy addr and channel
  26. ********************************************************************************
  27. */
  28. #ifndef __SHT3X_ATY_H
  29. #define __SHT3X_ATY_H
  30. #include "INCLUDE_ATY.h"
  31. #include "HW_TIMER_ATY.h"
  32. #include "HW_I2C_ATY.h"
  33. /******************************* For user *************************************/
  34. #define SHT3X_P_ADDR 0
  35. #define SHT3X_ADDR (0x44 | SHT3X_P_ADDR)
  36. // #define __DEBUG_SHT3X_ATY
  37. // #define SHT3X_I2C I2C_C1
  38. extern uint8_t Temperature[5];
  39. extern uint8_t Humidity[5];
  40. extern uint8_t TemperatureStr[5];
  41. extern uint8_t HumidityStr[5];
  42. extern uint8_t temperatureHexI; // integer
  43. extern uint8_t temperatureHexD; // decimal
  44. extern uint8_t humidityHexI;
  45. extern uint8_t humidityHexD;
  46. /******************************************************************************/
  47. // Generator polynomial for CRC
  48. #define POLYNOMIAL 0x131 // P(x) = x^8 + x^5 + x^4 + 1 = 100110001
  49. // Sensor Commands
  50. typedef enum{
  51. CMD_READ_SERIALNBR = 0x3780, // read serial number
  52. CMD_READ_STATUS = 0xF32D, // read status register
  53. CMD_CLEAR_STATUS = 0x3041, // clear status register
  54. CMD_HEATER_ENABLE = 0x306D, // enabled heater
  55. CMD_HEATER_DISABLE = 0x3066, // disable heater
  56. CMD_SOFT_RESET = 0x30A2, // soft reset
  57. CMD_MEAS_CLOCKSTR_H = 0x2C06, // measurement: clock stretching, high repeatability
  58. CMD_MEAS_CLOCKSTR_M = 0x2C0D, // measurement: clock stretching, medium repeatability
  59. CMD_MEAS_CLOCKSTR_L = 0x2C10, // measurement: clock stretching, low repeatability
  60. CMD_MEAS_POLLING_H = 0x2400, // measurement: polling, high repeatability
  61. CMD_MEAS_POLLING_M = 0x240B, // measurement: polling, medium repeatability
  62. CMD_MEAS_POLLING_L = 0x2416, // measurement: polling, low repeatability
  63. CMD_MEAS_PERI_05_H = 0x2032, // measurement: periodic 0.5 mps, high repeatability
  64. CMD_MEAS_PERI_05_M = 0x2024, // measurement: periodic 0.5 mps, medium repeatability
  65. CMD_MEAS_PERI_05_L = 0x202F, // measurement: periodic 0.5 mps, low repeatability
  66. CMD_MEAS_PERI_1_H = 0x2130, // measurement: periodic 1 mps, high repeatability
  67. CMD_MEAS_PERI_1_M = 0x2126, // measurement: periodic 1 mps, medium repeatability
  68. CMD_MEAS_PERI_1_L = 0x212D, // measurement: periodic 1 mps, low repeatability
  69. CMD_MEAS_PERI_2_H = 0x2236, // measurement: periodic 2 mps, high repeatability
  70. CMD_MEAS_PERI_2_M = 0x2220, // measurement: periodic 2 mps, medium repeatability
  71. CMD_MEAS_PERI_2_L = 0x222B, // measurement: periodic 2 mps, low repeatability
  72. CMD_MEAS_PERI_4_H = 0x2334, // measurement: periodic 4 mps, high repeatability
  73. CMD_MEAS_PERI_4_M = 0x2322, // measurement: periodic 4 mps, medium repeatability
  74. CMD_MEAS_PERI_4_L = 0x2329, // measurement: periodic 4 mps, low repeatability
  75. CMD_MEAS_PERI_10_H = 0x2737, // measurement: periodic 10 mps, high repeatability
  76. CMD_MEAS_PERI_10_M = 0x2721, // measurement: periodic 10 mps, medium repeatability
  77. CMD_MEAS_PERI_10_L = 0x272A, // measurement: periodic 10 mps, low repeatability
  78. CMD_FETCH_DATA = 0xE000, // readout measurements for periodic mode
  79. CMD_R_AL_LIM_LS = 0xE102, // read alert limits, low set
  80. CMD_R_AL_LIM_LC = 0xE109, // read alert limits, low clear
  81. CMD_R_AL_LIM_HS = 0xE11F, // read alert limits, high set
  82. CMD_R_AL_LIM_HC = 0xE114, // read alert limits, high clear
  83. CMD_W_AL_LIM_HS = 0x611D, // write alert limits, high set
  84. CMD_W_AL_LIM_HC = 0x6116, // write alert limits, high clear
  85. CMD_W_AL_LIM_LC = 0x610B, // write alert limits, low clear
  86. CMD_W_AL_LIM_LS = 0x6100, // write alert limits, low set
  87. CMD_NO_SLEEP = 0x303E,
  88. }sht3xCommands;
  89. // Measurement Repeatability
  90. typedef enum{
  91. REPEATAB_HIGH, // high repeatability
  92. REPEATAB_MEDIUM, // medium repeatability
  93. REPEATAB_LOW, // low repeatability
  94. }sht3xRepeatability;
  95. // Measurement Mode
  96. typedef enum{
  97. MODE_CLKSTRETCH, // clock stretching
  98. MODE_POLLING, // polling
  99. }sht3xMode;
  100. typedef enum{
  101. FREQUENCY_HZ5, // 0.5 measurements per seconds
  102. FREQUENCY_1HZ, // 1.0 measurements per seconds
  103. FREQUENCY_2HZ, // 2.0 measurements per seconds
  104. FREQUENCY_4HZ, // 4.0 measurements per seconds
  105. FREQUENCY_10HZ, // 10.0 measurements per seconds
  106. }sht3xFrequency;
  107. void SHT3X_InitBegin(uint8_t addr, uint8_t channel);
  108. void SHT3X_ReadMeasurementBuffer(uint8_t addr, uint8_t channel);
  109. #endif /* __SHT3X_ATY_H */
  110. /******************************** End Of File *********************************/