基于ESP8266_NONOS_SDK-2.2.0

os_timer_t OS_Timer_1;//定义软件定时器变量
int a=1;

void ICACHE_FLASH_ATTR OS_Timer_1_cb(void)//软件定时器的回调函数
{
	a=!a;
	gpio16_output_set(a);
	os_printf("\r-------------- into cb----------------\r\n");
}

void ICACHE_FLASH_ATTR OS_Timer_1_Init(u32 timemsm,bool time_repetitive)//软件定时器的初始化
{
	os_timer_disarm(&OS_Timer_1);//关闭软件定时器
	os_timer_setfn(&OS_Timer_1,(os_timer_func_t *)OS_Timer_1_cb,NULL);//设置定时器,设置回调函数
	os_timer_arm(&OS_Timer_1,timemsm, time_repetitive);//使能定时器
}

//主函数里面调用如下,即可实现500ms亮led,500ms灭
OS_Timer_1_Init(500,1);//软件定时器的初始化