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

📄 rtctest.c

📁 优龙 ARM9 FS2410开发板的BIOS源程序!
💻 C
字号:
#include "def.h"
#include "2410addr.h"
#include "2410lib.h"
#include "rtcapi.h"
#include "alarm.h"
#include "timer.h"

static volatile int AlarmWake;

static void AlarmNotify(void)
{
	AlarmWake = 1;
}

static void RtcTestCheck(U32 i)
{	
	static cnt = 10;
	
	if(!--cnt) {
		
		ReleaseBiosTimerEvent(i);
	}
}

void RtcTest(void)
{
	DATETIME_T dt;
	U32 i;	
	
	EnableModuleClock(CLOCK_RTC);
	
	RtcGetDate(&dt);
	RequestBiosTimerEvent(1);

	printf("Set date is %4d-%2d-%2d week %d, time is %2d:%2d:%2d\n", 
			dt1.year, dt1.month, dt1.day, dt1.week, dt1.hour, dt1.minute, dt1.second);
	RtcSetDate(&dt1);
	
	OpenAlarm(AlarmNotify);
	
	AlarmSetDate(&dt2);
	getalr = AlarmGetDate(&dt1);
		
	printf("Set alarm and enter idle mode...\n");
	AlarmWake = 0;
	rCLKCON	|= 1<<2;		//enter IDLE mode
	
	for(i=0; i<10; i++);	
	
	rCLKCON &= ~(1<<2);		//manual clear	
	
	CloseAlarm();

	printf("Wakeup from idle mode by alarm test %s\n", AlarmWake?"success":"fail");
	
	if(getalr)
		printf("alarm time = %4d-%2d-%2d %2d:%2d:%2d\n", dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute, dt1.second);
	else
		puts("Get alarm time fail\n");
	
	RtcGetDate(&dt1);
	printf("Now date is %4d-%2d-%2d week %d, time is %2d:%2d:%2d",
			dt1.year, dt1.month, dt1.day, dt1.week, dt1.hour, dt1.minute, dt1.second);	
}

⌨️ 快捷键说明

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