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

📄 timer_drv.c

📁 单片机开发程序原码,仅供个人学习参考. 各原码详细功能见压缩包及代码注释.
💻 C
字号:
/*C**************************************************************************
* NAME:         timer_drv.c
*----------------------------------------------------------------------------
* Copyright (c) 2003 Atmel.
*----------------------------------------------------------------------------
* RELEASE:      snd1c-refd-nf-4_0_3      
* REVISION:     1.2     
*----------------------------------------------------------------------------
* PURPOSE:
* This file contains the timer 0 & timer 1 driver routines.
*
* NOTES:
* Driver Configuration:
*   - T0_X2 & T1_X2 in config.h define as:
*      TRUE:  to set timer clock independant of X2/X1 mode
*      FALSE: to set timer clock dependant of X1/X2 mode
* Global Variables:
*   - None
* FT0_IN and FT1_IN must be used instead of FOSC-FPER for period calculation
*****************************************************************************/

/*_____ I N C L U D E S ____________________________________________________*/

#include "config.h"                         /* lib configuration header */
#include "timer_drv.h"                      /* timer driver definition */


/*_____ M A C R O S ________________________________________________________*/


/*_____ D E F I N I T I O N ________________________________________________*/


/*_____ D E C L A R A T I O N ______________________________________________*/



/*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;
  }
}

⌨️ 快捷键说明

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