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

📄 timer.c

📁 使用在cc1000芯片和avr128l处理器上的无线通讯新到监听程序,比较简单适合入门。
💻 C
字号:
/*
****************************************************************************
*              宁波中科集成电路设计中心  版权所有 Copyright 2005
*						http:\\www.nbicc.com
*文件名:  timer.h
*程序员:  夏鹏	xpsonny@nbicc.com
*主要内容  定时器

*如有问题或BUG,请登录www.wsn.net.cn 提问或用邮件和作者联系
****************************************************************************
*/

#include "timer.h"
#include "type.h"
#include "main.h"
#include "led.h"
static void TimerTimerFired(void);
static result_t TimerHPLClockSetRate(char interval, char scale);
enum {
  TimerM_maxTimerInterval = 230
};
static uint8_t TimerM_mScale;
static uint8_t TimerM_mInterval;

/*************************************************************************
*功能描述:0号计数器初始化参数设置
*参数说明:无
*返回值:  
**************************************************************************/
void TimerStdControlInit(void)
{
	TimerM_mScale = 3;
	TimerM_mInterval = TimerM_maxTimerInterval;
	TimerHPLClockSetRate(TimerM_mInterval, TimerM_mScale);
}

/*************************************************************************
*功能描述:0号计数器初始化
*参数说明:中断时间间隔interval,分频系数scale
*返回值:  成功
**************************************************************************/
static result_t TimerHPLClockSetRate(char interval, char scale)
{
	scale &= 0x7;
	scale |= 0x8;
	
    {
		* (volatile unsigned char *)(0x37 + 0x20) &= ~(1 << 0);
		* (volatile unsigned char *)(0x37 + 0x20) &= ~(1 << 1);
		* (volatile unsigned char *)(0x30 + 0x20) |= 1 << 3;
		
		
		* (volatile unsigned char *)(0x33 + 0x20) = scale;
		* (volatile unsigned char *)(0x32 + 0x20) = 0;
		* (volatile unsigned char *)(0x31 + 0x20) = interval;
		* (volatile unsigned char *)(0x37 + 0x20) |= 1 << 1;
    }
    
	return SUCCESS;
}

/*************************************************************************
*功能描述:0号计数器中断回调函数
*参数说明:无
*返回值:  
**************************************************************************/
static void TimerTimerFired(void)
{

	   Timer0_Fired() ;

}

/*************************************************************************
*功能描述:0号计数器中断函数
*参数说明:无
*返回值:  
**************************************************************************/
void __attribute((signal))  __vector_15(void)
{   
 	TimerTimerFired();
}

⌨️ 快捷键说明

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