?? drv_timer1.c
字號:
#include "config_60_61.h"
#include "include_GD61.h"
/////////////////////////////////////////////////////////////////////////////
void __irq IRQ_Timer1Serving (void);
void Timer1Initialize(void);
void TimeElapseStart(void);
void TimeElapseStop(char *TitlePt);
void DelayUS_(uint32 dly);
/////////////////////////////////////////////////////////////////////////////
void __irq IRQ_Timer1Serving(void)
{
//do something here.
T1IR = 0x01; /* 清除中斷標志 */
VICVectAddr = 0x00; /* 通知VIC中斷處理結束 */
}
/////////////////////////////////////////////////////////////////////////////
void Timer1Initialize(void)
{
//定時器1初始化
T1TC = 0; //set timer1 initialization value
T1PR = 0; //pclk output to timer1 directly
T1MCR = 0x03; /* 設置T1MR0匹配后復位T1TC,并產生中斷標志 */
T1MR0 = LPC_FPCLK/1000; /* 1/1000秒鐘定時 */
T1TCR = 0x01; /* 啟動定時器 ok */
//設置定時器1中斷IRQ
VICVectCntl5 = 0x20|INT_TIMER1; //enable int vector and assign priority of int.
VICVectAddr5 = (uint32)IRQ_Timer1Serving; //assign the address of int handler.
VICIntEnable = 1<<INT_TIMER1; //
}
/////////////////////////////////////////////////////////////////////////////
void TimeElapseStart(void)
{
//定時器1初始化
T1TC = 0; //set timer1 initialization value
T1PR = 0; //pclk output to timer1 directly
T1TCR = 0x01; /* 啟動定時器 */
}
/////////////////////////////////////////////////////////////////////////////
void TimeElapseStop(char *TitlePt)
{
char dbuffer[100];
uint32 buff;
T1TCR = 0x00; /* stop timer1*/
buff = T1TC;
buff = buff*100/1106 + buff*8/1106/1106; //11.0592
sprintf(dbuffer,"%s elapsed time: %d us = %d ms",TitlePt,buff,((buff+500)/1000));
DB_SendString(dbuffer);
}
/////////////////////////////////////////////////////////////////////////////
void DelayUS_(uint32 dly)
{
volatile uint32 us_buff;
volatile uint32 us_buff1;
volatile uint32 us_buff2;
us_buff = (dly>=500)? dly:500;
while(us_buff){
us_buff--;
us_buff1=12*us_buff; //dummy operation, only for delay time
us_buff1++;
us_buff2=us_buff1;
}
}
////////////////////////////////////////////////////////////////////////////
// end of file //
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -