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

📄 scheduler.c

📁 PLL的资料文档,包括资料
💻 C
字号:
/*C**************************************************************************
* NAME:         scheduler.c
*----------------------------------------------------------------------------
* Copyright (c) 2006 Atmel.
*----------------------------------------------------------------------------
* RELEASE:      C51 Sample      
* REVISION:     1.00     
*----------------------------------------------------------------------------
*
*****************************************************************************/
#include "system\reg51.h"
#include "system\compiler.h"
#include "system\config.h"
#include "scheduler.h"                      /* scheduler definition */
#include "task\kbd_task.h"
#include "task\disp_task.h"
#include "task\dts_task.h"

/*F**************************************************************************
* NAME:     sch_scheduler_init
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE: 
*   Scheduler initialization
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   Task_x_init() and Task_x_fct() are defined in scheduler.h
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void sch_scheduler_init (void)
{
	Task_1_init();
	Task_2_init();
	Task_3_init();
	DelayX10ms(150);   
	Task_4_init();  
	Task_5_init();  
	Task_6_init();  
	Task_7_init();  
	Task_8_init();  
	Task_9_init();  
	Task_10_init();
//  sch_time_init();                /* start time base */
}

/*F**************************************************************************
* NAME:     sch_scheduler
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Task execution scheduler 
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void sch_scheduler (void)
{
	while (1)
  	{
		Task_1_fct();
		Task_2_fct();
		Task_3_fct();
		Task_4_fct();
		Task_5_fct();
		Task_6_fct();
		Task_7_fct();
		Task_8_fct();
		Task_9_fct();
		Task_10_fct();
	}
}

/*F**************************************************************************
* NAME:     sch_time_init
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Scheduler time base (timer 0) initialization
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   mode 16-bit Timer, Time counter
*   T0_PRIO to be defined in config.h
*   TIM_LOW & TIM_HIGH defined in scheduler.h
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void sch_timer0_init (void)
{
	TMOD = TMOD |0x01;
	TL0 = TIM_LOW;
	TH0 = TIM_HIGH;
	//T0_enable_int();              /* enable interrupt */
	IE = IE | 0x82;
	//T0_start();                   /* start time base */
	TR0 = High;
	ET0 = High;
	EA = High;
} 
/*F**************************************************************************
* NAME:     timer0
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Timer 0 interrupt function
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
******************************************************************************/
void timer0(void) interrupt 1 using 2  
{
	TL0 = TIM_LOW;                /* reload timer */ 
	TH0 = TIM_HIGH;
  /* increment task tick counters */
	gl_cpt_tick++;                /* general timer */
	gl_kbd_tick++;                /* keyboard timer */
	gl_act_tick++;				/* Inactivity TIMER */
	vol_tick++;
	disp_tick++;
	touch_tick++;
	if(gl_cpt_tick> 50){
	 	P1_5 = ~P1_5;
	 	gl_cpt_tick = 0;
	 	}
	if(gl_kbd_tick >150)  gl_kbd_tick = 0;
	if(gl_act_tick >150)  gl_act_tick = 0;
	if(vol_tick >1000)  vol_tick = 0;
	if(disp_tick >150)  disp_tick = 0;
	if(touch_tick >150)  touch_tick = 0;

}

/*F**************************************************************************
* NAME: System_init
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE: 
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void System_init (void)
{
	I2c_init();

	DtsMen_flag = Low;
	Mem_add = Mem_StartAdd; /* DTS setp at 24c02 start address */
	DtsMen_flag = Low;		/* DTS mem pointer flag initializtion */
	dts_frequency = DTS_FreStart;		/* DTS frequency value initializtion */
	
	gl_kbd_tick = 0x00;
	gl_cpt_tick = 0x00;
	gl_act_tick = 0x00;
	vol_tick = 0x00;
	disp_tick = 0x00;
}

/*F**************************************************************************
* NAME: System_init
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE: 
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void Tick_init (void)
{
	gl_kbd_tick = 0x00;
	gl_cpt_tick = 0x00;
	gl_act_tick = 0x00;
	vol_tick = 0x00;
	disp_tick = 0x00;
	touch_tick = 0x00;
}

⌨️ 快捷键说明

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