eecs-bsp-test-code-2/4/main.c

44 lines
1.1 KiB
C

#include "DS1302.h"
#include "STC15F2K60S2.H"
#include "displayer.h"
#include "sys.h"
#include "universal_decode_table.h"
code unsigned long SysClock = 11059200; //必须。定义系统工作时钟频率(Hz),用户必须修改成与实际工作频率(下载时选择的)一致
struct_DS1302_RTC time, temp;
unsigned char display[8];
void changeClock()
{
temp = RTC_Read();
display[0] = temp.second & 0x0f;
display[1] = (temp.second >> 4) & 0x0f;
display[2] = temp.minute & 0x0f;
display[3] = (temp.minute >> 4) & 0x0f;
display[4] = temp.hour & 0x0f;
display[5] = (temp.hour >> 4) & 0x0f;
display[6] = temp.day & 0x0f;
display[7] = (temp.day >> 4) & 0x0f;
Seg7Print(display[7], display[6], display[5], display[4], display[3], display[2], display[1], display[0]);
}
void main()
{
time.year = 0x22;
time.day = 0x22;
time.month = 0x8;
time.hour = 0x15;
time.minute = 0x33;
time.second = 0x22;
DS1302Init(time);
DisplayerInit();
SetDisplayerArea(0, 7);
LedPrint(0);
SetEventCallBack(enumEventSys10mS, changeClock);
MySTC_Init();
while (1)
{
MySTC_OS();
}
}