BMx280.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. Unitemp - Universal temperature reader
  3. Copyright (C) 2022-2023 Victor Nikitchuk (https://github.com/quen0n)
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef UNITEMP_BMx280
  16. #define UNITEMP_BMx280
  17. #include "../unitemp.h"
  18. #include "../Sensors.h"
  19. #include "../interfaces/I2CSensor.h"
  20. typedef struct {
  21. uint16_t dig_T1;
  22. int16_t dig_T2;
  23. int16_t dig_T3;
  24. } BMx280_temp_cal;
  25. typedef struct {
  26. uint16_t dig_P1;
  27. int16_t dig_P2;
  28. int16_t dig_P3;
  29. int16_t dig_P4;
  30. int16_t dig_P5;
  31. int16_t dig_P6;
  32. int16_t dig_P7;
  33. int16_t dig_P8;
  34. int16_t dig_P9;
  35. } BMx280_press_cal;
  36. typedef struct {
  37. uint8_t dig_H1;
  38. int16_t dig_H2;
  39. uint8_t dig_H3;
  40. int16_t dig_H4;
  41. int16_t dig_H5;
  42. int8_t dig_H6;
  43. } BMx280_hum_cal;
  44. typedef struct {
  45. //Калибровочные значения температуры
  46. BMx280_temp_cal temp_cal;
  47. //Калибровочные значения давления
  48. BMx280_press_cal press_cal;
  49. //Калибровочные значения влажности воздуха
  50. BMx280_hum_cal hum_cal;
  51. //Время последнего обновления калибровочных значений
  52. uint32_t last_cal_update_time;
  53. //Индификатор датчика
  54. uint8_t chip_id;
  55. //Корректировочное значение температуры
  56. int32_t t_fine;
  57. } BMx280_instance;
  58. extern const SensorType BMP280;
  59. extern const SensorType BME280;
  60. /**
  61. * @brief Выделение памяти и установка начальных значений датчика BMP280
  62. * @param sensor Указатель на создаваемый датчик
  63. * @return Истина при успехе
  64. */
  65. bool unitemp_BMx280_alloc(Sensor* sensor, char* args);
  66. /**
  67. * @brief Инициализации датчика BMP280
  68. * @param sensor Указатель на датчик
  69. * @return Истина если инициализация упспешная
  70. */
  71. bool unitemp_BMx280_init(Sensor* sensor);
  72. /**
  73. * @brief Деинициализация датчика
  74. * @param sensor Указатель на датчик
  75. */
  76. bool unitemp_BMx280_deinit(Sensor* sensor);
  77. /**
  78. * @brief Обновление значений из датчика
  79. * @param sensor Указатель на датчик
  80. * @return Статус опроса датчика
  81. */
  82. UnitempStatus unitemp_BMx280_update(Sensor* sensor);
  83. /**
  84. * @brief Высвободить память датчика
  85. * @param sensor Указатель на датчик
  86. */
  87. bool unitemp_BMx280_free(Sensor* sensor);
  88. #endif