📄 main.c
字号:
//*----------------------------------------------------------------------------
//* ATMEL Microcontroller Software Support - ROUSSET -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name : main.c
//* Object : main application written in C
//* Creation : ODi 06/26/2002
//*
//*----------------------------------------------------------------------------
#include <stdarg.h>
#include "AT91RM9200.h"
#include "lib_AT91RM9200.h"
#include "rtc_pcf8563.h"
// AT91F_DBGU_Printk is defined in init.c
extern void AT91F_DBGU_Printk(char *);
void AT91F_DBGU_Printf(char *fmt,...)
{
va_list ap;
char string[256];
va_start(ap,fmt);
vsprintf(string,fmt,ap);
AT91F_DBGU_Printk(string);
va_end(ap);
}
//*----------------------------------------------------------------------------
//* \fn AT91F_DBGU_getc
//* \brief This function is used to receive a character to the DBGU channel
//*----------------------------------------------------------------------------
char AT91F_DBGU_Getc(void)
{
while (!AT91F_US_RxReady((AT91PS_USART)AT91C_BASE_DBGU));
return AT91F_US_GetChar((AT91PS_USART) AT91C_BASE_DBGU);
}
//* RTC PCF8563 TEST
//* Meterchen(CHENMENG) 20041200
int main()
{
unsigned int tick;
int i, flag=0;
#if 1
//* RTC test
AT91F_TWI_CfgPIO ();
AT91F_PIO_CfgOpendrain(AT91C_BASE_PIOA, (unsigned int) AT91C_PA25_TWD);
// Configure PMC by enabling TWI clock
AT91F_TWI_CfgPMC ();
// Configure TWI in master mode
AT91F_TWI_Configure (AT91C_BASE_TWI);
// Set TWI Clock Waveform Generator Register
AT91F_SetTwiClock(AT91C_BASE_TWI);
AT91F_DBGU_Printk("TWI ready\n\r");
{
struct rtc_time tmp;
char buf[64];
int i;
#if 1
tmp.tm_year = 2004;
tmp.tm_mon = 7;
tmp.tm_mday = 3;
tmp.tm_wday = 6;
tmp.tm_hour = 21;
tmp.tm_min = 17;
RTC_Set(&tmp);
#endif
while(1)
{
RTC_Get(&tmp);
sprintf(buf, "Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n\r",
tmp.tm_year, tmp.tm_mon, tmp.tm_mday, tmp.tm_wday,
tmp.tm_hour, tmp.tm_min, tmp.tm_sec);
/* output through COM0 */
AT91F_DBGU_Printk(buf);
/* sleep 10s */
for(i=0; i<200000; i++);
if(AT91F_US_RxReady((AT91PS_USART)AT91C_BASE_DBGU))
{
if( (AT91F_US_GetChar((AT91PS_USART)AT91C_BASE_DBGU)) == 'q')
break;
}
}
}
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -