main.c

来自「44b0开发板上实时时钟的测试程序」· C语言 代码 · 共 62 行

C
62
字号
#include <stdio.h>
#include <string.h>
//#include "44b.h"
#include "inc\common.h"
#include "inc\44blib.h"
#include "inc\rtc.h"

TIME_STRUC t;

extern char *WeekDay[7] ;


unsigned char Int2BCD(unsigned int num)
{

	return (unsigned char)(((num/10)<<4)|(num%10));
}

void SetRtc(void)
{
	uint i;	
	int y,a,b,c;
	Uart_Printf("Input Year[0-99]:");
	t.year = Int2BCD((unsigned char)Uart_GetNumForRtc());

	Uart_Printf("Input Month[1-12]:");
	t.month = Int2BCD((unsigned char)Uart_GetNumForRtc());
	
	
	Uart_Printf("Input Day[1-31]:");
	t.day = Int2BCD((unsigned char)Uart_GetNumForRtc());
	RtcSetDay(&t);

	Uart_Printf("Input weekday[1-7]:");
	t.weekday = Int2BCD((unsigned char)Uart_GetNumForRtc());	
	RtcSetWeek(&t);

	Uart_Printf("Input hour[0-23]:");
	t.hour = Int2BCD((unsigned char)Uart_GetNumForRtc());
	Uart_Printf("Input min[0-59]:");
	t.min = Int2BCD((unsigned char)Uart_GetNumForRtc());
	Uart_Printf("Input sec[0-59]:");
	t.sec = Int2BCD((unsigned char)Uart_GetNumForRtc());
	RtcSetTime(&t);
	
	RtcInit(&t);

}
int Main(void)
{


  	Board_Init();
	SetRtc();

	while(1)
	{

	Display_Rtc();
	Delay(20000);
	}
 }

⌨️ 快捷键说明

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