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

📄 timerjiffyasyncm.nc

📁 无线通信的主要编程软件,是无线通信工作人员的必备工具,关天相关教程我会在后续传上.
💻 NC
字号:
//$Id: TimerJiffyAsyncM.nc,v 1.1 2004/06/10 01:32:22 jpolastre Exp $// @author Joe Polastre/*****************************************************************************Provides a highresolution (32uSec interval) timer for CC2420Radio stackUses ATMega128 Timer2 via HPLTimer2*****************************************************************************/module TimerJiffyAsyncM{  provides interface StdControl;  provides interface TimerJiffyAsync;  uses interface Clock as Timer;}implementation{#define  JIFFY_SCALE 0x4 //cpu clk/256 ~ 32uSec#define  JIFFY_INTERVAL 2  uint32_t jiffy;  bool bSet;  command result_t StdControl.init()  {//    call Alarm.setControlAsTimer();    return SUCCESS;  }  command result_t StdControl.start()  {    atomic bSet = FALSE;    return SUCCESS;  }  command result_t StdControl.stop()  {    atomic {      bSet = FALSE;	  call Timer.intDisable();    }    return SUCCESS;  }//  async event void Alarm.fired()async event result_t Timer.fire() {	uint16_t localjiffy;	atomic localjiffy = jiffy;	if (localjiffy < 0xFF) {		call Timer.intDisable();		atomic bSet = FALSE;		signal TimerJiffyAsync.fired();  //finished!		}	else {      localjiffy = localjiffy >> 8;      atomic jiffy = localjiffy;      call Timer.setIntervalAndScale(localjiffy, JIFFY_SCALE  );  //sets timer,starts and enables interrupt    }	return(SUCCESS);  }  async command result_t TimerJiffyAsync.setOneShot( uint32_t _jiffy )  {    atomic {      jiffy = _jiffy;      bSet = TRUE;    }    if (_jiffy > 0xFF) {      call Timer.setIntervalAndScale(0xFF, JIFFY_SCALE  );  //sets timer,starts and enables interrupt    }    else {      call Timer.setIntervalAndScale(_jiffy, JIFFY_SCALE  );  // enables timer interrupt    }    return SUCCESS;  }  async command bool TimerJiffyAsync.isSet( )  {    return bSet;  }  async command result_t TimerJiffyAsync.stop()  {    atomic {       bSet = FALSE;      call Timer.intDisable();    }    return SUCCESS;  }}//TimerJiffyAsync

⌨️ 快捷键说明

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