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

📄 rtc_test.c

📁 s3c6400 ADS下官方测试程序
💻 C
字号:
/**************************************************************************************
* 
*	Project Name : S3C6400 Validation
*
*	Copyright 2006 by Samsung Electronics, Inc.
*	All rights reserved.
*
*	Project Description :
*		This software is only for validating functions of the S3C6400.
*		Anybody can use this software without our permission.
*  
*--------------------------------------------------------------------------------------
* 
*	File Name : RTC_test.c
*  
*	File Description : This file implements the API functons for RTC test.
*
*	Author : Woojin.Kim
*	Dept. : AP Development Team
*	Created Date : 2007/01/06
*	Version : 0.1 
* 
*	History
*	- Created(Woojin.Kim 2007/01/06)
*  
**************************************************************************************/


/* Include Files */


#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include "rtc.h"
#include "def.h"
#include "option.h"
#include "library.h"
#include "sfr6400.h"
#include "system.h"
#include "sysc.h"
#include "intc.h"
#include "gpio.h"
#include "timer.h"


u8 *aDay[8] = {" ","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
u32 uCntTick=0; 
u32 uCntAlarm=0;

void RTC_test(void);
void RTC_initialize(void);
void RTC_time_tick(void);
void RTC_Alarm(void);
void RTC_LVDetection(void);
void RTC_inspect_tick(void);



const testFuncMenu g_aRTCTestFunc[] =
{
	RTC_initialize,			"RTC time initialize        ",	
	RTC_time_tick,			"RTC Time Tick Int Test",
	RTC_inspect_tick,		"RTC Tick Count check",
	RTC_Alarm,				"RTC Alarm Test	",
	RTC_LVDetection,		"RTC battery falut(LowVoltage) check Test	",
	0,0
};

void RTC_test(void)
{
	u32 uCountFunc=0;
	s32 iSel=0;

	


	
	while(1)
	{
	printf("\n\n================== RTC Function Test =====================\n\n");
	
		for (uCountFunc=0; (u32)(g_aRTCTestFunc[uCountFunc].desc)!=0; uCountFunc++)
			printf("%2d: %s\n", uCountFunc, g_aRTCTestFunc[uCountFunc].desc);

		printf("\nSelect the function to test : ");
		iSel =GetIntNum();
		printf("\n");
		if(iSel == -1) 
			break;

		if (iSel>=0 && iSel<(sizeof(g_aRTCTestFunc)/8-1))
			(g_aRTCTestFunc[iSel].func) ();
	}
}	

//////////
// Function Name : RTC_initialize
// Function Description : This function test RTC initialize by pre-defined values
// Input : NONE
// Output : NONE (Print out RTC time)
// Version : v0.1


void RTC_initialize(void)
{

	
	RTC_SetCON(0,0,0,0,0,1);
	RTC_SetTime(6,12,31,3,23,59,20);
	
  	while (!UART_GetKey())
		{	

		RTC_Print();

		
  	}
}

//////////
// Function Name : RTC_time_tick
// Function Description : This function test RTC Tick Timer
// Input : NONE(user can choose tick timer sub clock)
// Output : NONE (you should see CLK_OUT port by osciloscope and check whether it's 2sec period)
// Version : v0.1

void RTC_time_tick(void)
{
	s32 sSelect;

	RTC_Init();

	while(1)
	{
		printf("[0]1/32768\t [1]:1/16384\t [2]1/8192\t [3]1/4096\n [4]1/2048\t [5]1/1024\t [6]1/512\t[7]1/256\n[8]1/128\t [9]1/64\t[10]1/32\t[11]1/16\n [12]1/8\t [13]1/4\t [14]1/2\t [15]1/1\n");
		printf("[0~15] : ");

		sSelect=GetIntNum();

		if (sSelect == -1)
		break;
		
		printf("\n");
		
		RTC_SetCON(0,sSelect,0,0,0,0);			//Select Tick Timer Sub Clock

	//	RTC_SetTickCNT(0x1);
		RTC_SetTickCNT(0x8000>>sSelect);

		INTC_SetVectAddr(NUM_RTC_TIC,Isr_RTC_Tick);



		RTC_ClearIntP(0);			//Clear Interrupt Pending
		

	// for checking tick interval
		SYSC_CtrlCLKOUT(eCLKOUT_TICK,0);    
		
	    RTC_SetCON(1,sSelect,0,0,0,1);			//Tick Timer Interrupt Enable with [RTC Control Enable(EVT0)]

		INTC_Enable(NUM_RTC_TIC);


		printf("Check Out CLK_OUT tp on B'd!!you will see TICK select frequency) \n");
		printf("Press any key to check TICK Interrupt\n\n\n");

		
		UART_Getc();
		
		SYSC_CtrlCLKOUT(eCLKOUT_RTC,0);    	
		printf("Now it will Print time out every 1sec by RTC TICK, Check it out!\n");



	   	while(!UART_GetKey()) {
	    		
	  		while(!uCntTick);	// Wait Tick Interrupt
			RTC_Print();
			uCntTick = 0;
		}

			
		RTC_SetCON(0,sSelect,0,0,0,0);	// Tick Time Interrupt Disable
		INTC_Disable(NUM_RTC_TIC);

		}

}


//////////
// Function Name : RTC_inspect_tick
// Function Description : This function test RTC Tick Disable Holding time
// Input : Key Input ( Making Disable )
// Output : NONE 
// Version : v0.1

void RTC_inspect_tick(void)
{
	RTC_Init();


	printf("\n");
	
	RTC_SetCON(0,0,0,0,0,0);			//Select Tick Timer Sub Clock

	RTC_SetTickCNT(0xffff);

	INTC_SetVectAddr(NUM_RTC_TIC,Isr_RTC_InspectTick);

	RTC_ClearIntP(0);			//Clear Interrupt Pending
	

	// for checking tick interval
	
	INTC_Enable(NUM_RTC_TIC);


	while(1)
	{
	   	RTC_SetCON(1,0,0,0,0,0);			//Tick Timer Interrupt Enable
		while(!UART_GetKey())
		{
			RTC_PrintCURTICK();
		}

		printf("Tick Disable Occured!!\n");
		RTC_SetCON(0,0,0,0,0,0)	;	// Tick Time Interrupt Disable
		DelayfrTimer(micro,35);		// Disable Holding time
		
		if(UART_GetKey()=='x')
			break;
	}
	
	INTC_Disable(NUM_RTC_TIC);

}


//////////
// Function Name : RTC_Alarm
// Function Description : This function test RTC Alarm function
// Input : NONE(pre-defined Alarm value at rtc.h and Alarm component selection by user)
// Output : NONE (Alarm Interrupt will occur when RTC reaches defined Alarm value by selecting component such as sec,min,etc)
// Version : v0.1

void RTC_Alarm(void)
{
	u32 uSelect;

	RTC_Init();	
	
    printf("[ RTC Alarm Test for S3C6400 ]\n");

	RTC_SetCON(0,0,0,0,0,1);		//No reset, Merge BCD counters, 1/32768, RTC Control enable


	RTC_SetAlmTime(AlmYear,AlmMon,AlmDate,AlmHour,AlmMin,AlmSec);

		
	printf("Select alarm interrupt source  \n");
	printf("1:sec 2:min 3:hour 4:date 5:month 6:year 7:All components\n");
		
	uSelect = GetIntNum();
	switch(uSelect)
	{
			case 1:
			RTC_SetAlmEn(1,0,0,0,0,0,1);
			break;

		case 2:
			RTC_SetAlmEn(1,0,0,0,0,1,0);
			break;
		case 3:
			RTC_SetAlmEn(1,0,0,0,1,0,0);
			break;
		case 4:
			RTC_SetAlmEn(1,0,0,1,0,0,0);
			break;
		case 5:
			RTC_SetAlmEn(1,0,1,0,0,0,0);
			break;
		case 6:
			RTC_SetAlmEn(1,1,0,0,0,0,0);
			break;
		case 7:
			RTC_SetAlmEn(1,1,1,1,1,1,1);
			break;

		default :
			RTC_SetAlmEn(1,1,1,1,1,1,1);
			break;
	}
		
	
	printf("After 5 sec, alarm interrupt will occur.. \n");
	RTC_PrintAlm();

	RTC_Print();

	
	uCntAlarm = 0;
	INTC_SetVectAddr(NUM_RTC_ALARM,Isr_RTC_Alm);
	INTC_Enable(NUM_RTC_ALARM);
    
	RTC_SetCON(0,0,0,0,0,0);                     //No reset, Merge BCD counters, 1/32768, RTC Control disable

	while(uCntAlarm==0)
	{
		
	};
	RTC_Print();

	INTC_Disable(NUM_RTC_ALARM);
	RTC_SetCON(0,0,0,0,0,0);	  //RTC  Control disable(for power consumption), 1/32768, Normal(merge), No reset}
	
}


//////////
// Function Name : RTC_LVDetection
// Function Description : This function test RTC Low Voltage Detection(LVD)
// Input : NONE(change RTC voltage)
// Output : NONE (RTCLVD register value)
// Version : v0.1

void RTC_LVDetection(void)
{
	u32 uTemp;
	
	RTC_SetCON(0,0,0,0,0,1);	//must be set "1"

	uTemp = RTC_PrintLVD();
	
	printf(" when check the register set to 1 varying the VDDrtc voltage\n");
	printf(" change the VDDrtc value !!!\n");
	printf(" Once LOWBAT bit set, although the VDDrtc power off, this register keep the value\n");	
	printf(" \n");
	printf(" Setup down the VDDRTC volatage !!!!=rtcbat= %08x\n",uTemp);


	RTC_SetLVD(1); // set "1" to clear this bit.
	

	uTemp = RTC_PrintLVD();
	
	printf("rtc cleared = %08x\n",uTemp);
		
	while ( uTemp != 1 )
	{

		printf(">\b");
		uTemp = RTC_PrintLVD();
	}; 

	printf(" Check the VDDrtc voltage, and then adjust the RTC time value\n");

	
	RTC_SetLVD(1);	// set "1" then cleared this bit.
	uTemp = RTC_PrintLVD();

	printf(" RTCBAT register = %08x\n",uTemp);

}






⌨️ 快捷键说明

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