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

當(dāng)前位置:首頁 > 單片機(jī) > 單片機(jī)
[導(dǎo)讀]********************************************************************************************************** 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í)間與當(dāng)前時(shí)間比較
// 函數(shù): int Cmp_now_time(UCHAR hr, UCHAR min, UCHAR sec)
// 語言: C
// 輸入:
// 輸出: 0 相等
// >0 給定時(shí)間大于當(dāng)前時(shí)間
// <0 給定時(shí)間小于當(dāng)前時(shí)間
//@@***********************************************************
//-------------------------------------------------------------
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í)間與當(dāng)前時(shí)間比較
// 函數(shù): int Cmp_now_date_time(UCHAR month, UCHAR day, UINT year, UCHAR hr, UCHAR min, UCHAR sec)
// 語言: C
// 輸入:
// 輸出: 0 相等
// >0 給定時(shí)間大于當(dāng)前時(shí)間
// <0 給定時(shí)間小于當(dāng)前時(shí)間
//@@***********************************************************
//-------------------------------------------------------------
#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


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

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

關(guān)鍵字: C51 數(shù)據(jù)類型 擴(kuò)充定義

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

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

▼點(diǎn)擊下方名片,關(guān)注公眾號(hào)▼歡迎關(guān)注【玩轉(zhuǎn)單片機(jī)與嵌入式】公眾號(hào),回復(fù)關(guān)鍵字獲取更多免費(fèi)資料?;貜?fù)【加群】,限時(shí)免費(fèi)進(jìn)入知識(shí)共享群;回復(fù)【3D封裝庫】,常用元器件的3D封裝庫;回復(fù)【電容】,獲取電容、元器件選型相關(guān)的內(nèi)容...

關(guān)鍵字: C51 MDK RealView

在Keil C51軟件中51單片機(jī)的中斷服務(wù)和外設(shè)驅(qū)動(dòng)程序的開發(fā)

關(guān)鍵字: keil5 編譯 C51

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

關(guān)鍵字: C51 KEIL 編程

c上標(biāo)3下標(biāo)5怎么算用計(jì)算機(jī),c上標(biāo)3下標(biāo)5怎么算

關(guān)鍵字: C51 KEIL

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

關(guān)鍵字: 51單片機(jī) C51

??匆姵鯇W(xué)者要求使用_at_,這是一種謬誤,把C當(dāng)作ASM看待了。在C中變量的定位是編譯器的事情,初學(xué)者只要定義變量和變量的作 用域,編譯器就把一個(gè)固定地址給這個(gè)變量。

關(guān)鍵字: C51 單片機(jī) 誤區(qū) 注意事項(xiàng)

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

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

如果你用 Keil C51 進(jìn)行編譯,記住一點(diǎn):它不區(qū)分大小寫!!!臥槽,今天編程序那個(gè)調(diào)錯(cuò)啊,就因?yàn)橐粋€(gè)數(shù)組名和一個(gè)變量名完全一樣,只是大小寫不一樣罷了,標(biāo)準(zhǔn) C 我怎么記得這樣可以啊……上網(wǎng)一查,臥槽,Keil C5...

關(guān)鍵字: C51 單片機(jī) 編程要點(diǎn)
關(guān)閉