⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clock.c

📁 以ST公司CPU为核心的彩色电视机的完整源程序。
💻 C
字号:
/********************** SGS-THOMSON MICROELECTRONICS ************************
FILENAME     : CLOCK.C
VERSION      : V1.0
DATE         : JAN 1999
AUTHOR(s)    : ASHISH RUDOLA/ DEEPAK DOSHI
PROCESSOR    : ST92195
DESCRIPTION  : This file contains the source code for handling the time of
               the day clock.
MODIFICATIONS:
	-
*****************************************************************************/

#include "register.h"
#include "timer.h"
#include "osdutil.h"
#include "alarm.h"
/*#include "utility.h"*/
#include "clock.h"
#include "sleep.h"


/* Time of day counters */
unsigned char hour;
unsigned char minute;
unsigned char second;

/*****************************************************************************
INPUTS     : none
OUTPUTS    : hour - Set to default value
             minute - Set to default value
             second - Set to default value
             SET_TIME - Flag to the display status a reset occured
             CLOCK_TIMER - Start time-of-day clock (1 second timer)
DESCRIPTION: This function sets the time-of-day clock to its default value.
*****************************************************************************/
void init_clock(void)
{

	/* Flag a reset occured */
	time_flags = time_flags | SET_TIME;
	user_flags = user_flags &~ SLEEP_ACTIVE;
	sleep_timer = 0 ;


	/* Set to default hour */
	hour = DISABLE_TIME;

	/* Set to default minute */
	minute = DISABLE_TIME;

	/* Set to default second */
	second = DISABLE_TIME;

	/* Start clock timer (1 seconds timer) */
	fast_timers[CLOCK_TIMER] = 1000/MS_PER_INTERRUPT;
	fast_timers[AFC_TIMER] = 300/MS_PER_INTERRUPT;

}

/*****************************************************************************
INPUTS     : CLOCK_TIMER - Modify the time of the day if equal to zero
OUTPUTS    : CLOCK_TIMER - Set to 1 second
             second - +1 every 1 second
             minute - +1 every minute
             hour - +1 every hour
             ONE_MINUTE - Flag to the main program one minute has elapsed
DESCRIPTION: This function checks if it is time to modify the time of the
             day clock.
*****************************************************************************/
void update_clock(void)
{
	/* Is it time to update the clock ? */
	if (fast_timers[CLOCK_TIMER] == 0)
	{
		/* Yes, increment seconds counter */
			second++;

		/* Is it time to update minutes ? */
		if (second >= 60)
		{
			/* Yes, increment minutes counter */
			minute++;
			second = 0;

			/* Flag one minute has elapsed */
			time_flags = time_flags | ONE_MINUTE;	/* 0x02	*/

			/* Is it time to update hours ? */
			if (minute == 60)
			{
				/* Yes, increment hours counter */
				hour++;
				minute = 0;

				/* Re-start from 0 if more than 24 hours a day !!! */
				if (hour == 24)
				{
					hour = 0;
				}
			}
		}
		/* Re-start clock timer */
		fast_timers[CLOCK_TIMER] = 1000/MS_PER_INTERRUPT;

		/* Flag one second has elapsed */
        time_flags = time_flags | ONE_SECOND ;

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -