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

📄 timer_drv.c

📁 atmel at89c51snd1c mp3芯片方案源码
💻 C
字号:

#include "config.h"                         /* lib configuration header */
#include "timer_drv.h"                      /* timer driver definition */
#include "lib_mcu\kbd\key_drv.h" 
#include "modules\display\disp_task.h"              /* display task definition */
#include "lib_mcu\remote\remote_drv.h"



INT8U   key_times = 0;

extern  bit  led_flush;
extern  Byte    key_int;

extern  bdata   bit     disp_clock_on;      /* set to TRUE to start clock */
extern  data    Byte    disp_sec_cpt;       /* second counter */
extern  data    Byte    disp_min_cpt;       /* minute counter */
extern  data    Byte    gl_cpt_tick;        /* general tick counter */
/*F***************************************************************************
* NAME: t0_set_prio
*-----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE: 
*   Set the Timer 0 priority interrupt
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
******************************************************************************/
void t0_set_prio (Byte priority)
{
  if ((priority == 1) || (priority == 3))     /* set LSB priority bit */
  {
    IPL0 |=  MSK_ET0;
  }
  if ((priority == 2) || (priority == 3))     /* set MSB priority bit */
  {
    IPH0 |= MSK_ET0;
  }
}


/*F***************************************************************************
* NAME: t1_set_prio
*-----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE: 
*   Set the Timer 1 priority interrupt
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
******************************************************************************/
void t1_set_prio (Byte priority)
{
  if ((priority == 1) || (priority == 3))     /* set LSB priority bit */
  {
    IPL0 |=  MSK_ET1;
  }
  if ((priority == 2) || (priority == 3))     /* set MSB priority bit */
  {
    IPH0 |= MSK_ET1;
  }
}


////////////////////////////////////////////////////////////////////////////////////////
void t0_init(void)
{
  T0_init(0,0,1);      //T0 Mode set
  T0_enable_int();     //T0 int enable
  T0_set_low(0x01);
  T0_set_high(0x00);
  T0_start();
}

////////////////////////////////////////////////////////////////////////////////////////
Interrupt(t0_int (void), IRQ_T0)
{ 
  T0_disable_int();
  T0_set_low(TIM_LOW);
  T0_set_high(TIM_HIGH);
  
  key_times ++;
  gl_cpt_tick ++;

  if (70 == key_times)   //conside as 1 second
  {  
     remote_enable();
     key_times = 0;
     led_flush = 1;
     key_int = KBSTA;
     //T0_stop();
     // Kbd_enable_int();
  }

  T0_enable_int();
}

⌨️ 快捷键说明

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