CELIS/APPLICATION/SecTimer/SecTimer.c

203 lines
4.6 KiB
C
Raw Normal View History

2024-08-09 06:24:48 +00:00
#include "SecTimer.h"
#include "timer.h"
#include "stm32f10x_rtc.h"
#include "mm_config.h"
#include "SEN_DCUMessage.h"
#include "Sleep.h"
#include "CDZ_State.h"
#include "Err_code.h"
struct SecTimer SecTimer[SecTimerNUM] = {0};
static uint32_t GetThisTime()
{
return RTC_GetCounter();
}
bool SecStar(struct SecTimer* obj,uint32_t longTime)
{
uint32_t ThisSecTime = RTC_GetCounter();
if(obj->Star_time == 0)
{
obj->Star_time = ThisSecTime;
obj->Endtime = longTime + obj->Star_time;
}
if(ThisSecTime>=obj->Endtime)
{
return true;
}
return false;
}
bool SecStop(struct SecTimer* obj)
{
obj->Star_time = 0;
obj->Endtime = 0;
return true;
}
struct CAN_SendMaster CanMasterOBJ = {
.obj = NULL,
.Master_len = 0,
};
void AddItemCAN_SendMaster(struct CAN_SendMaster* head,struct CAN_SendTimer* Item)
{
struct CAN_SendTimer* prtItem = (struct CAN_SendTimer*)MM_Malloc(sizeof(struct CAN_SendTimer));
prtItem->Arrcount = Item->Arrcount;
prtItem->can_send = Item->can_send;
if(head->obj==NULL)
{
head->Master_len = 1;
head->headH = prtItem;
prtItem->next=prtItem;
head->obj = prtItem;
return;
}
struct CAN_SendTimer* temp = head->obj;
while(temp->next != head->headH)
{
temp = temp->next;
}
temp->next = prtItem;
prtItem->next = head->obj;
return;
}
void Set_314FNM()
{
if(Sleep_Parame.False_sleep_State !=1)
ParseDCU_State_314();
}
void Set_3E8FNM()
{
if(Sleep_Parame.False_sleep_State !=1)
ParseDCU_State_3E8();
}
void Set_523FNM()
{
if(Sleep_Parame.False_sleep_State !=1)
ParseVHR_576();
}
#define offset_3E8 2500
#define offste_43F 1000
void InitCAN_SendMaster(void)
{
struct CAN_SendTimer ResterItem;
ResterItem.Arrcount = 5000-1;
ResterItem.can_send = Set_43FNM;//50
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = 10000-1;
ResterItem.can_send = Set_314FNM;//100
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = 5000-1-offset_3E8;
ResterItem.can_send = Set_314FNM;//200
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
//
ResterItem.Arrcount = 5000-1-offset_3E8;
ResterItem.can_send = Set_3E8FNM;//225
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
//
ResterItem.Arrcount = 5000-1;
ResterItem.can_send = Set_43FNM;//250
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
//
ResterItem.Arrcount = 10000-1-offste_43F;
ResterItem.can_send = Set_314FNM;//300
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
//
ResterItem.Arrcount = offste_43F-1;
ResterItem.can_send = Set_523FNM;//390----------
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
//
ResterItem.Arrcount = 5000-1;
ResterItem.can_send = Set_314FNM;//400
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
//
ResterItem.Arrcount = 5000-1-offset_3E8;
ResterItem.can_send = Set_43FNM;//450
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
//
ResterItem.Arrcount =0+offset_3E8-1;
ResterItem.can_send = Set_3E8FNM;//475
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = 10000-1;
ResterItem.can_send = Set_314FNM;//500
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = 5000-1;
ResterItem.can_send = Set_314FNM;//600
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = 5000-1;
ResterItem.can_send = Set_43FNM;//650
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = 5000-1-offset_3E8;;
ResterItem.can_send = Set_314FNM;//700
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = 10000-1-offset_3E8;
ResterItem.can_send = Set_3E8FNM;//725
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = 5000-1;
ResterItem.can_send = Set_314FNM;//800
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = 4000-1;
ResterItem.can_send = Set_43FNM;//850
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = offste_43F-1;
ResterItem.can_send = Set_523FNM;//890------------
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = 10000-1-offset_3E8;
ResterItem.can_send = Set_314FNM;//900
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = offset_3E8-1;
ResterItem.can_send = Set_3E8FNM;//975
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
ResterItem.Arrcount = 5000-1;
ResterItem.can_send = Set_314FNM;//1000
AddItemCAN_SendMaster(&CanMasterOBJ,&ResterItem);
}
void TimSend(void)
{
if(Err_Read(50) != true && Err_Read(42) != true){
TIM_SetAutoreload(TIM3,CanMasterOBJ.obj->Arrcount);
CanMasterOBJ.obj->can_send();
CanMasterOBJ.obj = CanMasterOBJ.obj->next;
// Loop_Send.CanData();
}
}