收到广播命令时重新初始化定时器,can总线添加发送时长超时判断

This commit is contained in:
ranchuan
2024-01-06 09:54:54 +08:00
parent 78e0ebd0c2
commit b9224f2293
11 changed files with 70 additions and 49 deletions

View File

@@ -8,7 +8,7 @@
static int init(timer_def *t){
static int inited=0;
if(inited!=0) return 0;
// if(inited!=0) return 0;
inited=1;
TIM_TimeBaseInitTypeDef timer;
@@ -58,10 +58,20 @@ static uint32_t read(timer_def *t)
}
static int write(timer_def *t,const uint32_t value)
{
uint32_t v;
TIM_Cmd(TIM4,DISABLE);
TIM_SetCounter(TIM4,(value%1000)*10);
TIM_SetCounter(TIM5,value/1000);
TIM_Cmd(TIM5,DISABLE);
v=(value%1000)*10;
TIM4->CNT = v;
TIM4->EGR |= TIM_EventSource_Update;
v=value/1000;
TIM5->CNT = v;
TIM5->EGR |= TIM_EventSource_Update;
TIM_Cmd(TIM4,ENABLE);
TIM_Cmd(TIM5,ENABLE);
return 0;
}