日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當前位置:首頁 > 單片機 > 單片機
[導讀]********************************************************************************************************** DETERMINE IF WE HAVE A LEAP YEAR** Description : This function determines whether the 'ye

*********************************************************************************************************
* DETERMINE IF WE HAVE A LEAP YEAR
*
* Description : This function determines whether the 'year' passed as an argument is a leap year.
* Arguments : year is the year to check for leap year.
* Returns : TRUE if 'year' is a leap year.
* FALSE if 'year' is NOT a leap year.
*********************************************************************************************************
*/
#if CLK_DATE_EN
static BOOL ClkIsLeapYear(UINT year)
{
if (!(year % 4) && (year % 100) || !(year % 400))
{
return TRUE;
}
else
{
return (FALSE);
}
}
#endif
/*
*********************************************************************************************************
* SET DATE ONLY
*
* Description : Set the date of the time-of-day clock
* Arguments : month is the desired month (1..12)
* day is the desired day (1..31)
* year is the desired year (CLK_TS_BASE_YEAR .. CLK_TS_BASE_YEAR+63)
* Returns : None.
* Notes : It is assumed that you are specifying a correct date (i.e. there is no range checking
* done by this function).
*********************************************************************************************************
*/
#if CLK_DATE_EN
void Clk_set_date (UCHAR month, UCHAR day, UINT year)
{
ENTER_CRITICAL();
ClkMonth = month;
ClkDay = day;
ClkYear = year;
ClkUpdateDOW();
EXIT_CRITICAL();
}
#endif
/*
*********************************************************************************************************
* SET DATE AND TIME
*
* Description : Set the date and time of the time-of-day clock
* Arguments : month is the desired month (1..12)
* day is the desired day (1..31)
* year is the desired year (2xxx)
* hr is the desired hour (0..23)
* min is the desired minutes (0..59)
* sec is the desired seconds (0..59)
* Returns : None.
* Notes : It is assumed that you are specifying a correct date and time (i.e. there is no range
* checking done by this function).
*********************************************************************************************************
*/

#if CLK_DATE_EN
void Clk_set_date_time (UCHAR month, UCHAR day, UINT year, UCHAR hr, UCHAR min, UCHAR sec)
{
ENTER_CRITICAL(); /* Gain exclusive access to time-of-day clock */
ClkMonth = month;
ClkDay = day;
ClkYear = year;
ClkHr = hr;
ClkMin = min;
ClkSec = sec;
ClkUpdateDOW(); /* Compute the day of the week (i.e. Sunday ...) */
EXIT_CRITICAL(); /* Release access to time-of-day clock */
}
#endif
/*
*********************************************************************************************************
* UPDATE THE DATE
*
* Description : This function is called to update the date (i.e. month, day and year)
* Arguments : None.
* Returns : None.
* Notes : This function updates ClkDay, ClkMonth, ClkYear and ClkDOW.
*********************************************************************************************************
*/
#if CLK_DATE_EN
static void ClkUpdateDate (void)
{
BOOL newmonth;

newmonth = TRUE;
if (ClkDay >= ClkMonthTbl[ClkMonth].MonthDays) { /* Last day of the month? */
if (ClkMonth == 2) { /* Is this February? */
if (ClkIsLeapYear(ClkYear) == TRUE) { /* Yes, Is this a leap year? */
if (ClkDay >= 29) { /* Yes, Last day in february? */
ClkDay = 1; /* Yes, Set to 1st day in March */
} else {
ClkDay++;
newmonth = FALSE;
}
} else {
ClkDay = 1;
}
} else {
ClkDay = 1;
}
} else {
ClkDay++;
newmonth = FALSE;
}
if (newmonth == TRUE) { /* See if we have completed a month */
if (ClkMonth >= 12) { /* Yes, Is this december ? */
ClkMonth = 1; /* Yes, set month to january... */
ClkYear++; /* ...we have a new year! */
} else {
ClkMonth++; /* No, increment the month */
}
}
ClkUpdateDOW(); /* Compute the day of the week (i.e. Sunday ...) */
}
#endif
/*
*********************************************************************************************************
* COMPUTE DAY-OF-WEEK
*
* Description : This function computes the day of the week (0 == Sunday) based on the current month,
* day and year.
* Arguments : None.
* Returns : None.
* Notes : - This function updates ClkDOW.
* - This function is called by ClkUpdateDate().
*********************************************************************************************************
*/
#if CLK_DATE_EN
static void ClkUpdateDOW (void)
{
UINT dow;

dow = ClkDay + ClkMonthTbl[ClkMonth].MonthVal;
if (ClkMonth < 3)
{
if (ClkIsLeapYear(ClkYear))
{
dow--;
}
}
dow += ClkYear + (ClkYear / 4);
dow += (ClkYear / 400) - (ClkYear / 100);
dow %= 7;
ClkDOW = dow;
}
#endif

//@@***********************************************************
//
// 功能: 給定的時間與當前時間比較
// 函數(shù): int Cmp_now_time(UCHAR hr, UCHAR min, UCHAR sec)
// 語言: C
// 輸入:
// 輸出: 0 相等
// >0 給定時間大于當前時間
// <0 給定時間小于當前時間
//@@***********************************************************
//-------------------------------------------------------------
int Cmp_now_time(UCHAR hr, UCHAR min, UCHAR sec)
{
if(ClkHr!=hr)
return(hr-ClkHr);
else if(ClkMin!= min)
return(min-ClkMin);
else
return(sec-ClkSec);
}

//@@***********************************************************
//
// 功能: 給定的時間與當前時間比較
// 函數(shù): int Cmp_now_date_time(UCHAR month, UCHAR day, UINT year, UCHAR hr, UCHAR min, UCHAR sec)
// 語言: C
// 輸入:
// 輸出: 0 相等
// >0 給定時間大于當前時間
// <0 給定時間小于當前時間
//@@***********************************************************
//-------------------------------------------------------------
#if CLK_DATE_EN
int Cmp_now_date_time(UCHAR month, UCHAR day, UINT year, UCHAR hr, UCHAR min, UCHAR sec)
{
if(ClkYear!=year)
return(year-ClkYear);
else if(ClkMonth!=month)
return(month-ClkMonth);
else if(ClkDay!=day)
return(day-ClkDay);
else if(ClkHr!=hr)
return(hr-ClkHr);
else if(ClkMin!= min)
return(min-ClkMin);
else
return(sec-ClkSec);
}
#endif


#endif


本站聲明: 本文章由作者或相關機構授權發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內容真實性等。需要轉載請聯(lián)系該專欄作者,如若文章內容侵犯您的權益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

單片機內部有很多的特殊功能寄存器,每個寄存器在單片機內部都分配有唯一的地址,一般我們會根據(jù)寄存器功能的不同給寄存器賦予各自的名稱,當我們需要在程序中操作這些特殊功能寄存器時,必須要在程序的最前面將這些名稱加以聲明,聲明的...

關鍵字: C51 數(shù)據(jù)類型 擴充定義

數(shù)據(jù)元(Data Element),也稱為數(shù)據(jù)元素,是用一組屬性描述其定義、標識、表示和允許值的數(shù)據(jù)單元,在一定語境下,通常用于構建一個語義正確、獨立且無歧義的特定概念語義的信息單元。數(shù)據(jù)元可以理解為數(shù)據(jù)的基本單元,將若...

關鍵字: C51 數(shù)據(jù)類型

▼點擊下方名片,關注公眾號▼歡迎關注【玩轉單片機與嵌入式】公眾號,回復關鍵字獲取更多免費資料?;貜汀炯尤骸?,限時免費進入知識共享群;回復【3D封裝庫】,常用元器件的3D封裝庫;回復【電容】,獲取電容、元器件選型相關的內容...

關鍵字: C51 MDK RealView

在Keil C51軟件中51單片機的中斷服務和外設驅動程序的開發(fā)

關鍵字: keil5 編譯 C51

Intel公司1980年推出了MCS-51系列單片機:集成 8位CPU、4K字節(jié)ROM、128字節(jié)RAM、4個8位并口、1個全雙工串行口、2個16位定時/計數(shù)器。尋址范圍64K,并有控制功能較強的布爾處理器。 80C5...

關鍵字: C51 KEIL 編程

c上標3下標5怎么算用計算機,c上標3下標5怎么算

關鍵字: C51 KEIL

▼點擊下方名片,關注公眾號▼大家好,很高興和各位一起分享我的第16篇原創(chuàng)文章,喜歡和支持我的工程師,一定記得給我點贊、收藏、分享。加微信[xyzn3333]與作者溝通交流,免費獲取更多單片機與嵌入式的海量電子資料。很多初...

關鍵字: 51單片機 C51

常看見初學者要求使用_at_,這是一種謬誤,把C當作ASM看待了。在C中變量的定位是編譯器的事情,初學者只要定義變量和變量的作 用域,編譯器就把一個固定地址給這個變量。

關鍵字: C51 單片機 誤區(qū) 注意事項

簡介:編程首要是要考慮程序的可行性,然后是可讀性、可移植性、健壯性以及可測試性。這是總則。但是很多人忽略了可讀性、可移植性和健壯性(可調試的方法可能歌不相同),這是不對的。

關鍵字: C51 編程規(guī)范 文件配置

如果你用 Keil C51 進行編譯,記住一點:它不區(qū)分大小寫!!!臥槽,今天編程序那個調錯啊,就因為一個數(shù)組名和一個變量名完全一樣,只是大小寫不一樣罷了,標準 C 我怎么記得這樣可以啊……上網(wǎng)一查,臥槽,Keil C5...

關鍵字: C51 單片機 編程要點
關閉