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.
41 lines
974 B
41 lines
974 B
|
|
#pragma once
|
|
#include <functional>
|
|
|
|
#include "basic/base.hpp"
|
|
|
|
#ifdef HAL_TIM_MODULE_ENABLED
|
|
|
|
namespace iflytop {
|
|
using namespace iflytop;
|
|
class ZPWMGenerator {
|
|
public:
|
|
typedef function<void()> ontimirq_t;
|
|
|
|
private:
|
|
zchip_tim_t *m_htim;
|
|
bool m_polarity;
|
|
uint32_t m_channel;
|
|
float m_freq;
|
|
|
|
public:
|
|
ZPWMGenerator() {}
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
* @param Channel PWM通道 TIM_CHANNEL_1 TIM_CHANNEL_2 TIM_CHANNEL_3 TIM_CHANNEL_4
|
|
* @param Polarity 1:高为有效电平,0:低为有效电平
|
|
*/
|
|
void initialize(zchip_tim_t *htim, uint32_t channel, float freq, bool polarity);
|
|
/*******************************************************************************
|
|
* PWM_MODE *
|
|
*******************************************************************************/
|
|
void startPWM(float freq, float duty);
|
|
void startPWM(float duty);
|
|
void stopPWM();
|
|
};
|
|
|
|
} // namespace iflytop
|
|
|
|
#endif
|