timer.h

来自「SOS操作系统用于无线传感器网络节点的源代码」· C头文件 代码 · 共 50 行

H
50
字号
#ifndef _TIMER_H
#define _TIMER_H
#include "hal.h"

#define PROCESSOR_TICKS(x) x

/**
 * @brief Initialize the timer hardware
 * @param interval Hardware timer interval
 * @param scale The hardware pre-scalar setting
 */
extern void timer_hardware_init(uint8_t interval, uint8_t scale);
/**
 * @brief Set a new value for the timer interval
 * @param val The value of the new interval
 */
extern void timer_setInterval(int32_t val);
// Timer Interrupt from hardware
//#define timer_interrupt()    SIGNAL(SIG_OUTPUT_COMPARE0)
// by zhou yajin
#define timer_interrupt()  __interrupt void T3_IRQ(void)
/**
 * @brief Get the current interval setting
 */
//BY ZHOU YA JIN WE USE TIMER3 OF CC2430
//static inline uint8_t timer_getInterval()   {return OCR0 + 1;}
static inline uint8_t timer_getInterval()   {return T3CC0 + 1;}
/**
 * @brief Get the current value stored in the hardware register
 */
//BY ZHOU YA JIN WE USE TIMER3 OF CC2430
static inline uint8_t timer_hardware_get_counter()
{
	return T3CNT;
}

static inline void timer_disable_interrupt()
{
	//TIMSK &= ~(1 << (OCIE0));
        T3IE=INT_ON;
}

static inline void timer_enable_interrupt()
{
	//TIMSK |= (1 << (OCIE0));
        T3IE=INT_OFF;
}

#endif // _TIMER_H

⌨️ 快捷键说明

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