📄 interrupt.c
字号:
//***************************************************************
// File Name : Interrupt.c
// Author : Steaven
// Created : 2008-06-09
// Modified :
// Revision : V0.0
//***************************************************************
#include "app.h"
//global variables definition
INT8U bYear; //time - year
INT8U bMonth; //time - month
INT8U bDate; //time - date
INT8U bHour; //time - hour
INT8U bMinute; //time - minute
INT8U bSecond; //time - second
//***************************************************************
// Function : sInit_Calendar
// Input : none
// Output : none
// Description : Time Initialization,2008-10-29,23:40:45
//***************************************************************
void sInit_Calendar(void)
{
bYear = 0x08;
bMonth = 10;
bDate = 29;
bHour = 23;
bMinute = 40;
bSecond = 45;
}
//***************************************************************
// Function : Calendar_Update
// Input : none
// Output : none
// Description : Update time every one second
//***************************************************************
void Calendar_Update(void)
{
bSecond++;
if(bSecond >= 60)
{
bSecond = 0;
bMinute++;
if(bMinute >= 60)
{
bMinute = 0;
bHour++;
if(bHour >= 24)
{
bHour = 0;
bDate++;
if((bMonth == 4) || (bMonth == 6) || \
(bMonth == 9) || (bMonth == 11))
{
if(bDate > 30)
{
bDate = 1;
bMonth++;
}
}
else if((bMonth == 1) || (bMonth == 3) || \
(bMonth == 5) || (bMonth == 7) || \
(bMonth == 8) || (bMonth == 10) || \
(bMonth == 12))
{
if(bDate > 31)
{
bDate = 1;
bMonth++;
}
}
else if(bMonth == 2)
{
if(bDate > 28)
{
if((bYear % 4) != 0)
{
bDate = 1;
bMonth++;
}
else
{
if(bDate > 29)
{
bDate = 1;
bMonth++;
}
}
}
}
if(bMonth > 12)
{
bMonth = 1;
bYear++;
}
}
}
}
}
//***************************************************************
// Function : Timer2_Interrupt
// Input : none
// Output : none
// Description : Kernel Clock Interrupt Service Routine
//***************************************************************
#pragma interrupt_handler Timer2_Interrupt:4
void Timer2_Interrupt(void)
{
//Clear Timer2 OCIF Flag
TIFR |= 0x80;
TCNT2 = 0x00;
//Update Task Status
OS_Task_Update();
}
//===========================END OF FILE========================//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -