BMP280.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. Unitemp - Universal temperature reader
  3. Copyright (C) 2022 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_BMP280
  16. #define UNITEMP_BMP280
  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. } BMP280_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. } BMP280_press_cal;
  36. typedef struct {
  37. //Калибровочные значения температуры
  38. BMP280_temp_cal temp_cal;
  39. //Калибровочные значения давления
  40. BMP280_press_cal press_cal;
  41. //Время последнего обновления калибровочных значений
  42. uint32_t last_cal_update_time;
  43. //Корректировочное значение температуры
  44. uint32_t t_fine;
  45. } BMP280_instance;
  46. extern const SensorType BMP280;
  47. /**
  48. * @brief Выделение памяти и установка начальных значений датчика BMP280
  49. * @param sensor Указатель на создаваемый датчик
  50. * @return Истина при успехе
  51. */
  52. bool unitemp_BMP280_alloc(Sensor* sensor, char* args);
  53. /**
  54. * @brief Инициализации датчика BMP280
  55. * @param sensor Указатель на датчик
  56. * @return Истина если инициализация упспешная
  57. */
  58. bool unitemp_BMP280_init(Sensor* sensor);
  59. /**
  60. * @brief Деинициализация датчика
  61. * @param sensor Указатель на датчик
  62. */
  63. bool unitemp_BMP280_deinit(Sensor* sensor);
  64. /**
  65. * @brief Обновление значений из датчика
  66. * @param sensor Указатель на датчик
  67. * @return Статус опроса датчика
  68. */
  69. UnitempStatus unitemp_BMP280_update(Sensor* sensor);
  70. /**
  71. * @brief Высвободить память датчика
  72. * @param sensor Указатель на датчик
  73. */
  74. bool unitemp_BMP280_free(Sensor* sensor);
  75. #endif