#ifndef Luat_PWM_H #define Luat_PWM_H #include "luat_base.h" /** * @defgroup luatos_device_PWM PWM接口 * @{ */ /** * @brief PWM控制参数 */ typedef struct luat_pwm_conf { int channel; /**channel: 选择PWM通道 可选通道为 0 / 1 / 2 / 4 总计4个通道 * conf->period : 设置产生的PWM频率 * conf->pulse : 设置产生的PWM占空比 * conf->pnum : 设置产生的PWM个数,若pnum设为0将一直输出PWM * @return int * 返回值为 0 : 配置PWM成功 * 返回值为 -1: PWM通道选择错误 * 返回值为 -2: PWM频率设置错误 * 返回值为 -3:PWM占空比设置错误 * 返回值为 -4: 该PWM通道已被使用 */ int luat_pwm_setup(luat_pwm_conf_t* conf); /** * @brief 获取pwm 频率 本功能暂未实现 * * @param id i2c_id * @return int */ int luat_pwm_capture(int channel,int freq); /** * @brief 关闭pwm 接口 * * @param channel: 选择PWM通道 可选通道为 0 / 1 / 2 / 4 总计4个通道 * @return int */ int luat_pwm_close(int channel); /** * @brief 修改占空比 * @param channel: 选择pwm通道 可选通道为 0 / 1 / 2 / 4 总计4个通道 * pulse :修改pwm占空比值 * @return int */ int luat_pwm_update_dutycycle(int channel, size_t pulse); /** @}*/ #endif