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

📄 basic.c

📁 RTC programming in eCos.
💻 C
字号:
//============================================================================
//        Include
//============================================================================

#include <stdio.h>
#include <cyg/kernel/kapi.h>
#include <cyg/io/rtc/fie702x_rtc.h>
#include "RTCSystem.h"

//============================================================================
//        Global Variables
//============================================================================

cyg_io_handle_t rtc_handle;

int main (void)
{	
	RTC_Time mytime;
	RTC_Date mydate;	
	int err;	
	
	/* open rtc driver
	*/
	err = cyg_io_lookup( "/dev/rtc", &rtc_handle );

	if (ENOERR != err) 
	{
		printf("Can't open '%s'\n", "/dev/rtc");
	}
	
	API_RTC_set_RecTime(rtc_handle, 0x1234);
	
	printf("record time = %d\n", API_RTC_get_RecTime(rtc_handle));
  
  while (1)
  {
  	cyg_thread_delay(100);
  	
		API_RTC_get_Date(rtc_handle, &mydate);
		API_RTC_get_Time(rtc_handle, &mytime);
	
		printf("\nYear:%d Month:%d Day:%d\n",mydate.year,mydate.month,mydate.day);
		printf("Hour:%d Min:%d Sec:%d\n",mytime.hour,mytime.minute,mytime.second);
	}
	
	return 0;
}

⌨️ 快捷键说明

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