基质喷涂
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
681 B

3 weeks ago
  1. #include "zgpio.hpp"
  2. using namespace iflytop;
  3. void ZGPIO::initAsInput(Pin_t pin, zaf_gpio_mode_t mode, zaf_gpio_irq_t irqtype, bool mirror) {
  4. inited = true;
  5. zaf_gpio_init_as_input(&m_gpio, pin, mode, irqtype, mirror);
  6. }
  7. void ZGPIO::initAsOutput(Pin_t pin, zaf_gpio_mode_t mode, bool mirror, bool initLevel) {
  8. zaf_gpio_init_as_output(&m_gpio, pin, mode, mirror, initLevel);
  9. inited = true;
  10. }
  11. bool ZGPIO::read() {
  12. if (!inited) {
  13. return false;
  14. }
  15. return zaf_gpio_read(&m_gpio);
  16. }
  17. void ZGPIO::write(bool level) {
  18. if (!inited) {
  19. return;
  20. }
  21. zaf_gpio_write(&m_gpio, level);
  22. }
  23. void ZGPIO::toggle() {
  24. if (!inited) {
  25. return;
  26. }
  27. zaf_gpio_toggle(&m_gpio);
  28. }