testostimeridget.c

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

C
70
字号
#include "timerTest.h"

int testOSTimerIdGet()
{
    OS_STATUS status;
    unsigned32 t_id1,t_id2,t_id3;
 
 	printf("*** test of OSTimerIdGet ***\n");
 	printf("create two timers.\n");
    status = OSTimerCreate  ("T1" , &t_id1);
  		if (status != OS_OK)
    	{
    		printf("OSTimerCreate error:[%s]\n",serrno(errno));   
    		return -1; 
		}    
    	else
    		printf("the id of TIMER1  is[%d]\n",t_id1);
    	
    status = OSTimerCreate  ("T2" , &t_id2);
  		if (status != OS_OK)
    	{
    		printf("OSTimerCreate error:[%s]\n",serrno(errno));   
    		return -1; 
		}    
    	else
    		printf("the id of TIMER2  is[%d]\n",t_id2);
    	
	status =  OSTimerIdGet  ("T1",&t_id3); 
    if (status != OS_OK)
    {
    	printf("OSTimerIdGet error:[%s]\n",serrno(errno));
    	return -1;
    }
    else
    {
		if(t_id1 == t_id3)
      		printf("the id of TIMER1 got by OSTimerIdGet is right[%d]\n",t_id3);
  		else
  		{
        	printf("the id of TIMER1 got by OSTimerIdGet is wrong[%d]\n",t_id3);
        	return -1;
        }
    }
 
    status =  OSTimerIdGet  ("T2",&t_id3); 
    if (status != OS_OK)
    {
    	printf("OSTimerIdGet error:[%s]\n",serrno(errno));
    	return -1;
    }
    else
    {
		if(t_id2 == t_id3)
      		printf("the id of TIMER2 got by OSTimerIdGet is right[%d]\n",t_id3);
  		else
  		{
        	printf("the id of TIMER2 got by OSTimerIdGet is wrong[%d]\n",t_id3);
        	return -1;
        }
    }
    	
	
  	OSTimerDelete(t_id1);
  	OSTimerDelete(t_id2);
  	printf("*** OSTimerIdGet test OK! ***\n");
    return 1;
}    


⌨️ 快捷键说明

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