📄 drv_timer.c
字号:
/***********************************************************************
* MODULE: drv_timer.c
* Description: Timer Driver
* Runtime Env: ARM7TDMI - KS32C50100
* Company:
* Change History:
* 03-28-02 Create (Yadong Wang)
***********************************************************************/
#include "common_types.h"
#include "samsung4510.h"
#include "main.h"
static void tm0isr(void);
static int timeout0;
// define Timer data block, and pass in as iopb
tU32 DrvTimerInit(tU32 Dev)
{
// Disable the interrupt, Disable_Int(nTIMER1_INT);
Disable_Int(nTIMER0_INT);
// Install Vector
SysSetInterrupt(nTIMER0_INT, tm0isr);
// timer output pin enable if requested
// IOPCON |= 0x40000000;
// IOPMOD |= 0x10000;
// Enable the timer with the toggle mode
TMOD = 0x00000003;
// Enable the INT, Enable_Int(nTIMER1_INT);
Enable_Int(nTIMER0_INT);
timeout0 = 0;
return 0;
}
static void tm0isr()
{
timeout0 = 1;
INTPEND |= TIMER0_INT;
}
tU32 DrvTimerArm(tU32 DevId, tU32 Timeout)
{
TMOD &= ~0x01;
TDATA0 = Timeout * fMCLK_MHZ;
TMOD |= 0x01;
return 0;
}
tU32 DrvTimerTimeout(tU32 Dev)
{
if (timeout0)
{
timeout0 = 0;
return 1;
}
else
return 0;
}
void Delay(tU32 n /* n in micro second */)
{
tU32 i;
// IOPDATA |= 0x00000001;
DrvTimerArm(0, n);
while(1)
{
if (DrvTimerTimeout(0))
break;
for(i=0; i<10; i++);
}
// IOPDATA &= ~0x00000001;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -