SPISensor.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_SPI
  16. #define UNITEMP_SPI
  17. #include "../unitemp.h"
  18. #include <furi_hal_spi.h>
  19. //Структура SPI датчика
  20. typedef struct SPISensor {
  21. //Указатель на интерфейс SPI
  22. FuriHalSpiBusHandle* spi;
  23. //Порт подключения CS
  24. const GPIO* CS_pin;
  25. } SPISensor;
  26. /**
  27. * @brief Выделение памяти для датчика с интерфейсом SPI
  28. * @param sensor Указатель на датчик
  29. * @param args Указатель на массив аргументов с параметрами датчика
  30. * @return Истина если всё ок
  31. */
  32. bool unitemp_spi_sensor_alloc(Sensor* sensor, char* args);
  33. /**
  34. * @brief Высвобождение памяти инстанса датчика
  35. * @param sensor Указатель на датчик
  36. */
  37. bool unitemp_spi_sensor_free(Sensor* sensor);
  38. /**
  39. * @brief Инициализации датчика с интерфейсом one wire
  40. * @param sensor Указатель на датчик
  41. * @return Истина если инициализация упспешная
  42. */
  43. bool unitemp_spi_sensor_init(Sensor* sensor);
  44. /**
  45. * @brief Деинициализация датчика
  46. * @param sensor Указатель на датчик
  47. */
  48. bool unitemp_spi_sensor_deinit(Sensor* sensor);
  49. /**
  50. * @brief Обновить значение с датчка
  51. * @param sensor Указатель на датчик
  52. * @return Статус обновления
  53. */
  54. UnitempStatus unitemp_spi_sensor_update(Sensor* sensor);
  55. #endif