#include "wm_include.h"
#include "wm_timer.h"
unsigned char led[]={WM_IO_PB_05,WM_IO_PB_25,WM_IO_PB_26,WM_IO_PB_18,WM_IO_PB_17,WM_IO_PB_16,WM_IO_PB_11};
int n=0;
bool colse=false;
static void demo_timer_irq(u8 *arg)
{
tls_gpio_write(led[n], colse); //0亮灯 1灭灯
n++;
if(n>6){
n=0;
colse=!colse;
}
}
int timer_demo(void)
{
u8 timer_id;
struct tls_timer_cfg timer_cfg;
timer_cfg.unit = TLS_TIMER_UNIT_MS;
timer_cfg.timeout = 500;//定时时间单位ms,1000 ->1S
timer_cfg.is_repeat = true;
timer_cfg.callback = (tls_timer_irq_callback)demo_timer_irq;
timer_cfg.arg = NULL;
timer_id = tls_timer_create(&timer_cfg);
tls_timer_start(timer_id);
printf("timer start\n");
return WM_SUCCESS;
}
void UserMain(void)
{
printf("\n Hello World! \r\n");
#if DEMO_CONSOLE
CreateDemoTask();
#endif
//用户自己的task
for(int i=0;i<7;i++){
tls_gpio_cfg(led[i], WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);//将GPIO口设置为输出模式,上拉
}
timer_demo();
}