api-gpio.h 881 B

12345678910111213141516171819202122232425262728293031323334353637
  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(GpioPin* gpio, GpioMode mode);
  13. // init GPIO, extended version
  14. void gpio_init_ex(GpioPin* gpio, GpioMode mode, GpioPull pull, GpioSpeed speed);
  15. // write value to GPIO, false = LOW, true = HIGH
  16. static inline void gpio_write(GpioPin* gpio, bool state) {
  17. hal_gpio_write(gpio, state);
  18. }
  19. // read value from GPIO, false = LOW, true = HIGH
  20. static inline bool gpio_read(const GpioPin* gpio) {
  21. return hal_gpio_read(gpio);
  22. }
  23. // put GPIO to Z-state
  24. void gpio_disable(GpioDisableRecord* gpio_record);
  25. // get GPIO record
  26. ValueMutex* gpio_open_mutex(const char* name);
  27. // get GPIO record and acquire mutex
  28. GpioPin* gpio_open(const char* name);