testostasktimerfireafter.c

来自「RTOS -REWORKS 定时器的例子」· C语言 代码 · 共 49 行

C
49
字号
#include "timerTest.h"

void tt_entry(unsigned32 id , void *data)
{
	printk("[%s]\n",data);
}
int testOSTaskTimerFireAfter()
{
	OS_STATUS	status;
	char*		t_name; 
	unsigned32	t_id;
  	
	printf("*** test of OSTaskTimerFireAfter ***\n");
	printf("create a timer.\n");
 	status = OSTimerCreate  ("TIMER" , &t_id);
  	if (status != OS_OK)
    {
    	printf("OSTimerCreate error:[%s]\n",serrno(errno));
    	return -1;
    }    
    	
    printf("start the timer server task.\n");
 	status = OSTaskTimerInit(1 , 2048 , OS_DEFAULT);
  	if (status != OS_OK)
    {
    	printf("OSTaskTimerInit error:[%s]\n",serrno(errno));
    	return -1;
    }
    	
	printf("fire the task timer for 5000 ticks.\n");
    status = OSTaskTimerFireAfter   (t_id , 5000 , tt_entry , "OSTaskTimerFireAfter:in timer");
    if (status != OS_OK)
    {
    	printf("OSTaskTimerFireAfter error:[%s]\n",serrno(errno));
    	return -1;
    }    
    else
    	printf("OSTaskTimerFireAfter OK\n");
    	
	OSTaskDelay(6000);
	
 	OSTimerDelete (t_id); 
 
  	printf("*** OSTaskTimerFireAfter test OK! ***\n");
	return 1;
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?