📄 ttim55.c.bak
字号:
//test timer 55
#ifndef _TTIM55_C
#define _TTIM55_C
#include <stdio.h>
#include "includes.h"
#include "ttim55.h"
void InitTimer(Uint16 tim_no,Uint32 prd)
{
Uint16 old_intm=0,eventId=0;
IRQ_Configs cfgTTimerIrq={TimerIsr,3};
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(TIMER_DEV1, TIMER_OPEN_RESET);
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);
/* Get the Configuration */
TIMER_getConfig(hTTimer, &cfgTTimer);
eventId = TIMER_getEventId(hTTimer);
IRQ_clear(eventId);
IRQ_config(eventId, &cfgTTimerIrq);
IRQ_enable(eventId);
IRQ_globalRestore(old_intm);
/* Start the timer */
TIMER_start(hTTimer) ;
}
Uint16 tim_cnt=0,ledtim=0;
void TimerIsr(void)
{
// printf("timer is running:tick %d\n",tim_cnt);
tim_cnt++;
tim_cnt=tim_cnt&0x7fff;
if((tim_cnt&0x7f)==0){
WrGpio(1,ledtim);
ledtim=ledtim^0x01;
}
// IRQ_enable(22);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -