You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
654 B

12 months ago
  1. #pragma once
  2. #include "zbasic.h"
  3. namespace iflytop {
  4. class ZGPIO {
  5. private:
  6. zaf_gpio_t m_gpio;
  7. bool inited = false;
  8. public:
  9. ZGPIO() {};
  10. void initAsInput(Pin_t pin, zaf_gpio_mode_t mode, zaf_gpio_irq_t irqtype, bool mirror);
  11. void initAsOutput(Pin_t pin, zaf_gpio_mode_t mode, bool mirror, bool initLevel);
  12. bool read();
  13. int32_t readint32() { return read() ? 1 : 0; }
  14. void write(bool level);
  15. void toggle();
  16. bool isInited() { return inited; }
  17. Pin_t pin() { return m_gpio.pin; }
  18. GPIO_TypeDef* port() { return m_gpio.gpio; }
  19. uint32_t pinoff() { return m_gpio.pinoff; }
  20. };
  21. } // namespace iflytop