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.

40 lines
974 B

  1. #pragma once
  2. #include <functional>
  3. #include "basic/base.hpp"
  4. #ifdef HAL_TIM_MODULE_ENABLED
  5. namespace iflytop {
  6. using namespace iflytop;
  7. class ZPWMGenerator {
  8. public:
  9. typedef function<void()> ontimirq_t;
  10. private:
  11. zchip_tim_t *m_htim;
  12. bool m_polarity;
  13. uint32_t m_channel;
  14. float m_freq;
  15. public:
  16. ZPWMGenerator() {}
  17. /**
  18. * @brief
  19. *
  20. * @param Channel PWMͨ TIM_CHANNEL_1 TIM_CHANNEL_2 TIM_CHANNEL_3 TIM_CHANNEL_4
  21. * @param Polarity 1:ΪЧƽ0ΪЧƽ
  22. */
  23. void initialize(zchip_tim_t *htim, uint32_t channel, float freq, bool polarity);
  24. /*******************************************************************************
  25. * PWM_MODE *
  26. *******************************************************************************/
  27. void startPWM(float freq, float duty);
  28. void startPWM(float duty);
  29. void stopPWM();
  30. };
  31. } // namespace iflytop
  32. #endif