ttim55.c
来自「TI OMAP5910(1510)的最简单测试程序,用于 硬件最初的调试,简要」· C语言 代码 · 共 72 行
C
72 行
//test timer 55
#ifndef _TTIM55_C
#define _TTIM55_C
#include <stdio.h>
#include "includes.h"
#include "ttim55.h"
Uint16 tim_cnt=0,ledtim=0;
void InitTimer(Uint16 tim_no,Uint32 prd)
{
Uint16 old_intm=0,eventId=0,i=0;
TIMER_Setup setTTimer={0, //period
0x0ffff,//PTV
TIMER_TCR_AR_RESET}; //auto reload
if(tim_no>2){
printf("timer no. %d is invalid\n",tim_no);
puts("valid timer no.:0/1\n");
return;
}
old_intm = IRQ_globalDisable();
hTTimer = TIMER_open(tim_no, TIMER_OPEN_RESET);
TIMER_stop(hTTimer);
cfgTTimer.tcr = TIMER_TCR_DEFAULT;
cfgTTimer.Lth = prd>>16;
cfgTTimer.Ltl = prd&0xFFFF;
/* Configure the Timer */
// printf("tim_no=%d ,prd_h=%u,prd_l=%u \n",tim_no,cfgTTimer.Lth,cfgTTimer.Ltl);
TIMER_config(hTTimer, &cfgTTimer);
TIMER_setup(hTTimer, &setTTimer);
/* Get the Configuration */
TIMER_getConfig( hTTimer , &cfgTTimer);
eventId = TIMER_getEventId(hTTimer);
IRQ_clear(eventId);
IRQ_plug(eventId, TimerIsr,3);
IRQ_enable(eventId);
IRQ_globalRestore(old_intm);
/* Start the timer */
TIMER_start(hTTimer) ;
printf("t%d\n",i++);
}
void TimerIsr(void)
{
// printf("timer is running:tick %d\n",tim_cnt);
//IRQ_globalDisable();
if((tim_cnt&0x7f)==0){
ledtim=ledtim^0x01;
WrGpio(1,ledtim);
//printf("led=%d\n",ledtim);
}
tim_cnt++;
tim_cnt=tim_cnt&0x7fff;
// IRQ_enable(22);
//IRQ_globalEnable();
//TIMER_start(hTTimer) ;
}
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?