📄 app.c
字号:
#include "avr/io.h"
#include "util/delay.h"
#include "ds1302.h"
#include "uart.h"
unsigned char Year;
unsigned char Month;
unsigned char Day;
unsigned char Hour;
unsigned char Minute;
unsigned char Second;
int main(void)
{
/* Set LED and Smg LE pin as output , databus as output */
DDRA |=(1<<PA4)|(1<<PA5)|(1<<PA6);
DDRB = 0xFF;
/* Off the Smg display */
PORTA|= (1<<PA5);
PORTB = 0x00;
PORTA&=~(1<<PA5);
/* Off the LED display */
PORTA|= (1<<PA6);
PORTB = 0xFF;
PORTA&=~(1<<PA6);
DS1302_Config();
DS1302TimeInit();
UART_Config();
printf("System reset ! \r\n");
while(1)
{
Year =DS1302TimeRead(DS_YEAR );
Month =DS1302TimeRead(DS_MONTH );
Day =DS1302TimeRead(DS_DAY );
Hour =DS1302TimeRead(DS_HOUR );
Minute=DS1302TimeRead(DS_MINUTE);
Second=DS1302TimeRead(DS_SECOND);
_delay_ms(10);
if(Second!=DS1302TimeRead(DS_SECOND))
{
Second=DS1302TimeRead(DS_SECOND);
printf("20%02d-%02d-%02d %02d:%02d:%02d\r\n",Year,Month,Day,Hour,Minute,Second);
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -