📄 rtc_test.c
字号:
/*******************************************************************
Analog Devices, Inc. All Rights Reserved.
This software is proprietary and confidential. By using this software
you agree to the terms of the associated Analog Devices License Agreement.
Project Name: Power_On_Self_Test
Hardware: ADSP-BF518F EZ-Board
Description: This file tests the real-time clock (RTC) interface
on the EZ-Board.
*******************************************************************/
/*******************************************************************
* include files
*******************************************************************/
#include <cdefBF518.h>
#include <ccblkfn.h>
/*******************************************************************
* global variables and defines
*******************************************************************/
/*******************************************************************
* function prototypes
*******************************************************************/
int SET_RTC(void);
int CHECK_RTC(void);
/*******************************************************************
* Function: SET_RTC
* Description: resets the RTC
*******************************************************************/
int SET_RTC(void)
{
*pRTC_PREN = 1; /* enable prescaler so RTC runs at 1 Hz */
while ((*pRTC_ISTAT&0x8000)==0); /* wait for writes to complete */
while ((*pRTC_ISTAT&4)==0); /* wait for seconds event */
*pRTC_STAT = 0; /* reset clock */
while ((*pRTC_ISTAT&0x8000)==0); /* wait for writes to complete */
return 1;
}
/*******************************************************************
* Function: CHECK_RTC
* Description: performs a check on the RTC
*******************************************************************/
int CHECK_RTC(void)
{
/* we make sure the day (bits 31:17) and hour (bits 16:12) counters
are still zero, this gives the tester up to one hour to set and
check the RTC */
unsigned int rtcstat = *pRTC_STAT;
/* if any day or hour bits are set the test will return 0 (failure) */
if (rtcstat & 0xfffff000)
return 0;
else
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -