【已提供】RTL8720CF的开发框架,可以直接使用 pwm 引脚 (A18) 为 LED 供电,有示例代码吗

Wi-Fi 设备、Wi-Fi 低功耗设备、Wi-Fi BLE 双模设备、Ethernet设备、Ethernet+Wi-Fi设备等
Post Reply
走走停停
Posts: 98

您好,请问在没有驱动器/IC 的情况下直接使用 pwm 引脚 (A18) 为 LED 供电,这可能吗?有没有示例代码
SDK: Wind IDE 3.3.1版本

一个网友
Posts: 5
Location: ⭐星星⭐

Re: 【求助】RTL8720CF

您好,

1、在没有驱动器/IC 的情况下直接使用 pwm 引脚 (A18) 为 LED 供电

普通led灯珠是可以的,这个得看具体led灯电压/电流等参数 是否匹配模组IO电器参数
Image
参考链接:https://developer.tuya.com/cn/docs/iot/ ... ujs2k5nriy

2、适合条件的led可以通过GPIO驱动或者PWM驱动

Code: Select all

#include "tkl_gpio.h"
#include "tkl_pwm.h"
#include "tal_thread.h"
STATIC TKL_THREAD_HANDLE ty_led_test_thread = NULL;
static void tuya_led_test_thread( void *arg )
{
	OPERATE_RET rt = OPRT_OK;

#if 1   // use GPIO
	TUYA_GPIO_BASE_CFG_T cfg;
	cfg.mode = TUYA_GPIO_PUSH_PULL;
	cfg.direct = TUYA_GPIO_OUTPUT;
	cfg.level = TUYA_GPIO_LEVEL_LOW;
	TUYA_CALL_ERR_GOTO(tkl_gpio_init(TUYA_GPIO_NUM_18, &cfg), __EXIT);
	while(1) {
		TUYA_CALL_ERR_GOTO(tkl_gpio_write(TUYA_GPIO_NUM_18,TUYA_GPIO_LEVEL_HIGH), __EXIT);
		tal_system_sleep(500);
		TUYA_CALL_ERR_GOTO(tkl_gpio_write(TUYA_GPIO_NUM_18,TUYA_GPIO_LEVEL_LOW), __EXIT);
		tal_system_sleep(500);
	}

#else // use PWM
	TUYA_PWM_BASE_CFG_T cfg;
	cfg.duty = 5000; /* 1-10000 */
	cfg.frequency = 2;
	cfg.polarity  = TUYA_PWM_NEGATIVE;
	TUYA_CALL_ERR_GOTO(tkl_pwm_init(TUYA_PWM_NUM_4, &cfg), __EXIT);
	TUYA_CALL_ERR_GOTO(tkl_pwm_start(TUYA_PWM_NUM_4), __EXIT);
	PR_NOTICE("PWM%d start", TUYA_PWM_NUM_4);
	while (1) {
		// do something
		tal_system_sleep(2000);
	}

#endif

__EXIT:
	(void)arg;
	tal_thread_delete(ty_led_test_thread);
	ty_led_test_thread = NULL;
	return;
}

努力写bug……

Post Reply