You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
1.9 KiB
100 lines
1.9 KiB
/*
|
|
* BHBF_ROBOT.c
|
|
*
|
|
* Created on: Oct 26, 2023
|
|
* Author: shiya
|
|
*/
|
|
#include "fsm.h"
|
|
#include "BHBF_ROBOT.h"
|
|
#include <string.h>
|
|
#include "bsp_FDCAN.h"
|
|
|
|
int32_t SystemTimeMiliCount; //2ms加一
|
|
|
|
//初始化定时器
|
|
Sys_timer_handler timer_handler_1;
|
|
Sys_timer_handler timer_handler_2;
|
|
Sys_timer_handler timer_handler_3;
|
|
Sys_timer_handler timer_handler_4;
|
|
|
|
//7 motors
|
|
MotorParameters *Motor[3];
|
|
//Motor Error
|
|
int32_t *Motor_ID_Errors[3] =
|
|
{ 0 };
|
|
//ComError
|
|
|
|
int32_t* SystemErrorCode;
|
|
ErrorData* SystemErrorData;
|
|
TT_MotorParameters* TT_Motor[4];
|
|
|
|
//Declare a CV and initialize CV
|
|
CV_struct_define CV =
|
|
{ 0 };
|
|
//Declare a GV and initialize CV
|
|
GV_struct_define GV =
|
|
{ 0 };
|
|
//Declare a PV and initialize CV
|
|
|
|
//PV_struct_define PV ={ 0 };
|
|
|
|
|
|
IV_struct_define IV ={ 0 };
|
|
|
|
void GF_MainLoop_Jump(int32_t Next_Index_U, int32_t Next_Index_N);
|
|
|
|
|
|
void SET_BIT_1(int32_t* num,int32_t k)
|
|
{
|
|
*num=((*num) | (1 << (k)));
|
|
}
|
|
void SET_BIT_0(int32_t* num,int32_t k)
|
|
{
|
|
*num=((*num) & ~(1 << (k)));
|
|
}
|
|
int32_t Get_BIT(int32_t* num,int32_t k)
|
|
{
|
|
// return (*num >> (k -1)) & 1;
|
|
return (*num >> (k)) & 1;
|
|
}
|
|
|
|
//100ms执行一次
|
|
void GF_WatchDog_Loop()
|
|
{
|
|
//硬件看门狗复位
|
|
//HAL_GPIO_TogglePin(RST_WDI_GPIO_Port, RST_WDI_Pin); //Hardware Watchdog,kicking the dog
|
|
|
|
//硬件看门狗复位
|
|
|
|
}
|
|
|
|
//比较计数值
|
|
bool CompareTimer(int32_t DelayMiliSeconds,Sys_timer_handler * timer_handler)
|
|
{
|
|
if(timer_handler->start_timer==1)
|
|
{
|
|
timer_handler->sys_current_timer_count=DelayMiliSeconds/2+SystemTimeMiliCount;
|
|
timer_handler->start_timer=0;
|
|
}
|
|
if(timer_handler->sys_current_timer_count<=SystemTimeMiliCount)
|
|
{
|
|
return true;
|
|
}else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
//定时数数
|
|
void GF_Timer_Count()
|
|
{
|
|
SystemTimeMiliCount++;
|
|
}
|
|
//将数数写入定时器
|
|
void SystemTimer_Intialize()
|
|
{
|
|
SystemTimeMiliCount=0;
|
|
GF_BSP_Interrupt_Add_CallBack(
|
|
DF_BSP_InterCall_TIM8_2ms_PeriodElapsedCallback, GF_Timer_Count);
|
|
}
|
|
|
|
|