api-gpio.h 946 B

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