一、API
1、開定時器中斷
//********************************************************************************************* //函數名稱:CurieTimerOne.start(int timerPeriodUsec, userCallBack) //輸入參數:timerPeriodUsec:: 多少微妙產生中斷 // userCallBack : 中斷函數 //函數返回:無 //函數功能:開定時器中斷 //********************************************************************************************* CurieTimerOne.start(int timerPeriodUsec, userCallBack);
2、重定義定時器時間
//********************************************************************************************* //函數名稱:CurieTimerOne.restart(int timerPeriodUsec) //輸入參數:timerPeriodUsec:: 多少微妙產生中斷 //函數返回:無 //函數功能:重開定時器中斷時間 //********************************************************************************************* CurieTimerOne.restart(int timerPeriodUsec);
3、關中斷,恢復為上電狀態
//********************************************************************************************* //函數名稱:CurieTimerOne.kill() //輸入參數:無 //函數返回:無 //函數功能:關中斷 //********************************************************************************************* CurieTimerOne.kill();
4、重配置定時器中斷函數
//********************************************************************************************* //函數名稱:CurieTimerOne.attachInterrupt(userCallBack) //輸入參數:userCallBack:中斷函數 //函數返回:無 //函數功能:配置中斷函數 //********************************************************************************************* CurieTimerOne.attachInterrupt(userCallBack);
5、取消配置此中斷函數,但定時器不停止
//********************************************************************************************* //函數名稱:CurieTimerOne.detachInterrupt() //輸入參數:無 //函數返回:無 //函數功能:取消配置中斷函數 //********************************************************************************************* CurieTimerOne.detachInterrupt();
6、返回觸發的中斷次數
//********************************************************************************************* //函數名稱:CurieTimerOne.readTickCount()
//輸入參數:無 //函數返回:中斷次數 //函數功能:返回觸發的中斷次數 //********************************************************************************************* CurieTimerOne.readTickCount();
7、重置中斷次數
//********************************************************************************************* //函數名稱:rdRstTickCount() //輸入參數:無 //函數返回:中斷次數 //函數功能:返回觸發的中斷次數並重置 //********************************************************************************************* rdRstTickCount();
8、暫停定時器中斷
//********************************************************************************************* //函數名稱:CurieTimerOne.pause() //輸入參數:無 //函數返回:無 //函數功能:暫停定時器中斷 //********************************************************************************************* CurieTimerOne.pause();
9、PWM生成
//********************************************************************************************* //函數名稱:CurieTimerOne.pwmStart(int outputPin, int dutyRange, unsigned int periodUsec) //輸入參數:outputPin 輸出管腳 // dutyRange 范圍是0到1023,對應0到100占空比 // periodUsec : Hz=(periodUsec/1000000) //函數返回:無 //函數功能:PWM //********************************************************************************************* CurieTimerOne.pwmStart(int outputPin, int dutyRange, unsigned int periodUsec) ; //********************************************************************************************* //函數名稱:CurieTimerOne.pwmStart(int outputPin, double dutyPercentage, unsigned int periodUsec) //輸入參數:outputPin 輸出管腳 // dutyPercentage, 占空比 // periodUsec : Hz=(periodUsec/1000000) //函數返回:無 //函數功能:PWM //********************************************************************************************* CurieTimerOne.pwmStart(int outputPin, double dutyPercentage, unsigned int periodUsec) ;
10、關PWM,設置管腳狀態為LOW
//********************************************************************************************* //函數名稱:CurieTimerOne.pwmStop() //輸入參數:無 //函數返回:無 //函數功能:關PWM //********************************************************************************************* CurieTimerOne.pwmStop() ;