📄 init.c
字号:
#include <cdefBF532.h>
#include <sys\exception.h> //contain interrupt_kind enumeration
EX_INTERRUPT_HANDLER(RTC_ISR);
void Init_RTC(void)
{
*pRTC_ICTL = 0x4;
*pRTC_PREN = 0x1;
// int current_time = *pRTC_STAT;
// printD("time is %x", current_time);
}
void Init_Interrupts(void)
{
*pSIC_IAR0 = 0x1fffffff;
*pSIC_IAR1 = 0xffffffff;
*pSIC_IAR2 = 0xffffffff; // RTC
// assign ISRs to interrupt vectors
register_handler(ik_ivg8, RTC_ISR); // RTC ISR -> IVG 8
// enable RTC interrupt
*pSIC_IMASK = 0x00000080;
}
EX_INTERRUPT_HANDLER(RTC_ISR)
{
// confirm interrupt handling
*pRTC_ISTAT = 0x0004;
int sec,min,hor,day,time;
time = *pRTC_STAT;
sec = time & 0x3f;
min = (time>>6) & 0x3f;
hor = (time>>12) & 0x1f;
day = (time>>17) & 0x7fff;
printD("\nTime is %d:%d:%d:%d\n",day,hor,min,sec);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -