{
OPERATE_RET rt = OPRT_OK;
UINT32_T frequency = PWM_FREQUENCY;
UINT32_T count = 0;
Code: Select all
/*pwm init*/
TUYA_PWM_BASE_CFG_T pwm_cfg = {
.duty = PWM_DUTY, /* 1-10000 */
.frequency = PWM_FREQUENCY,
.polarity = TUYA_PWM_NEGATIVE,
};
TUYA_CALL_ERR_GOTO(tkl_pwm_init(PWM_ID, &pwm_cfg), __EXIT);
/*start PWM3*/
TUYA_CALL_ERR_GOTO(tkl_pwm_start(PWM_ID), __EXIT);
TAL_PR_NOTICE("PWM%d start", PWM_ID);
while (1) {
/*Frequency, duty cycle settings*/
pwm_cfg.frequency = frequency;
TUYA_CALL_ERR_LOG(tkl_pwm_info_set(PWM_ID, &pwm_cfg)); //If tkl_pwm_frequency_set is implemented, you can call this function.
TUYA_CALL_ERR_LOG(tkl_pwm_start(PWM_ID));
TAL_PR_NOTICE("PWM%d , frequency: %d", PWM_ID, frequency);
/*close pwm*/
if(count >= 3) {
break;
}
count++;
frequency = frequency+10000;
tal_system_sleep(2000);
}
TUYA_CALL_ERR_LOG(tkl_pwm_stop(PWM_ID));
__EXIT:
TAL_PR_NOTICE("PWM task is finished, will delete");
tal_thread_delete(sg_pwm_handle);
return;
}
demo少了tkl_io_pin_to_func设置接口,内部能完善一下demo吗