api-gpio.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include "api-hal-gpio.h"
  3. #include <furi/valuemutex.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct {
  8. ValueMutex* gpio_mutex;
  9. GpioPin* gpio;
  10. } GpioDisableRecord;
  11. // init GPIO API
  12. bool gpio_api_init();
  13. // init GPIO
  14. void gpio_init(const GpioPin* gpio, const GpioMode mode);
  15. // init GPIO, extended version
  16. void gpio_init_ex(
  17. const GpioPin* gpio,
  18. const GpioMode mode,
  19. const GpioPull pull,
  20. const GpioSpeed speed);
  21. // write value to GPIO, false = LOW, true = HIGH
  22. static inline void gpio_write(const GpioPin* gpio, const bool state) {
  23. hal_gpio_write(gpio, state);
  24. }
  25. // read value from GPIO, false = LOW, true = HIGH
  26. static inline bool gpio_read(const GpioPin* gpio) {
  27. return hal_gpio_read(gpio);
  28. }
  29. // put GPIO to Z-state
  30. void gpio_disable(GpioDisableRecord* gpio_record);
  31. // get GPIO record
  32. ValueMutex* gpio_open_mutex(const char* name);
  33. // get GPIO record and acquire mutex
  34. GpioPin* gpio_open(const char* name);
  35. // get RFID IN level
  36. bool get_rfid_in_level();
  37. #ifdef __cplusplus
  38. }
  39. #endif