⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testosclockset.c

📁 RTOS -REWORKS 定时器的例子
💻 C
字号:
#include <reworks/clock.h>
#include <ucore/error.h>
#include <stdio.h>

int testOSClockSet()
{
	OS_STATUS	status;
	os_tod		new_time; 
	os_tod		current_time;

 	printf("*** test of OSClockSet ***\n");	
 	status = OSClockGet (OS_TOD_GET,&current_time);
  	if (status != OS_OK)
  	{
    	printf("OSClockGet error:[%s]\n",serrno(errno));   
    	return -1;
	}	
    else
		printf("the current time is %d.%d.%d,%d:%d:%d:%d\n",
  					current_time.year,
       				current_time.month,
           			current_time.day,
              		current_time.hour,
                	current_time.minute,
                 	current_time.second,
                 	current_time.ticks);
  	printf("now set the time to 2002.10.26,7:18:16:15\n");
	new_time.year = 2002;
	new_time.month= 10;
	new_time.day= 26;
    new_time.hour= 7;
    new_time.minute= 18;
    new_time.second= 16;
    new_time.ticks= 15;
 	status = OSClockSet ((os_tod *)&new_time);
  	if (status != OS_OK)
  	{
    	printf("OSClockSet error:[%s]\n",serrno(errno));   
    	return -1;
	}	
   
 	status = OSClockGet (OS_TOD_GET,&current_time);
  	if (status != OS_OK)
  	{
    	printf("OSClockGet error:[%s]\n",serrno(errno));   
    	return -1; 
	}	
    else
		printf("the time after set is %d.%d.%d,%d:%d:%d:%d\n",
  					current_time.year,
       				current_time.month,
           			current_time.day,
              		current_time.hour,
                	current_time.minute,
                 	current_time.second,
                 	current_time.ticks);
                 	
	printf("*** OSClockSet test OK! ***\n");
    return 1;
}


⌨️ 快捷键说明

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