testostimerfireafter.c

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

C
39
字号
#include "timerTest.h"

void t1_entry(unsigned32 id , void *data)
{
	printk("\n\n\n\n\n\n\n\n\n\n[%s]\n",data);
}
int testOSTimerFireAfter()
{
	OS_STATUS	status;
	unsigned32	t_id;
  	
	printf("*** test of OSTimerFireAfter ***\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("fire the timer for 3000 ticks.\n");
    status = OSTimerFireAfter  (t_id , 3000 , t1_entry , "OSTimerFireAfter:in timer");
    if (status != OS_OK)
    {
    	printf("OSTimerFireAfter error:[%s]\n",serrno(errno));
    	return -1;
    }  
    
    printf("task Delay 4000 ticks.\n");	
	OSTaskDelay(4000);

	OSTimerDelete (t_id); 
   	
	printf("*** OSTimerFireAfter test OK! ***\n");
	return 1;
}


⌨️ 快捷键说明

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