148 lines
2.2 KiB
C
148 lines
2.2 KiB
C
|
|
#include "apptasks.h"
|
|
|
|
#if (CUR_CORE_BOARD == CORE_BOARD_APP)
|
|
|
|
#include "inout.h"
|
|
#include "trigger.h"
|
|
#include "shell.h"
|
|
#include "fram.h"
|
|
#include "buttons.h"
|
|
#include "embfpga.h"
|
|
#include "extendboards.h"
|
|
#include "operator.h"
|
|
#include "paras.h"
|
|
#include "corefmc.h"
|
|
#include "workctrl.h"
|
|
#include "error.h"
|
|
#include "encrypt.h"
|
|
|
|
void TaskPreMainLoop(void);
|
|
|
|
void AppMainTask(void)
|
|
{
|
|
SetDefaultOut();
|
|
|
|
InitTrigger(); // 初始化定时触发功能
|
|
|
|
InitShell(); // 初始化Shell命令
|
|
|
|
InitFram();
|
|
|
|
InitButtonCtrl(); // 初始化按钮控制
|
|
|
|
InitEmbFpga();
|
|
|
|
InitDatFiles(); // 初始化数据文件
|
|
|
|
InitMotos(); // 初始化电机控制
|
|
|
|
InitExtendBoards(); // 初始化CAN扩展总线及挂载CAN总线上的板卡
|
|
|
|
InitOperator(); // 初始化操作箱
|
|
|
|
InitParas(); // 初始化参数
|
|
|
|
printf("\r\n================== Application ==================\r\n");
|
|
|
|
InitCoreFmc();
|
|
|
|
InitWorkCtrl(); // 初始化控制
|
|
|
|
TaskPreMainLoop(); // 一次性任务
|
|
|
|
do
|
|
{
|
|
TriggerTask(); //
|
|
|
|
ShellTask(); //
|
|
|
|
ExtendBoardTask();
|
|
|
|
ButtonsTask();
|
|
|
|
WorkCtrlTask();
|
|
|
|
OperatorTask();
|
|
|
|
#if (0) // 测试循环速度
|
|
static u32 timer = 0;
|
|
static u32 temp;
|
|
static int runcount = 0;
|
|
|
|
runcount++;
|
|
|
|
temp = GetMsSoftTimer();
|
|
if (temp - timer >= 1000)
|
|
{
|
|
timer = temp;
|
|
printf("run circle = %d/s\r\n", runcount);
|
|
runcount = 0;
|
|
}
|
|
#endif
|
|
|
|
}while(1);
|
|
|
|
}
|
|
|
|
void TaskPreMainLoop(void)
|
|
{
|
|
int err;
|
|
u16 ver;
|
|
|
|
AddTriggerToList(500, SetLedToggle, NULL); // 500ms 闪灯任务
|
|
|
|
SetNewParasFlag(PARA_VALID);
|
|
RefreshParas(PARA_VALID);
|
|
|
|
RegDelayFun(DelayRef);
|
|
|
|
CheckEncrypt(); // 检查加密情况.....
|
|
|
|
do
|
|
{
|
|
TriggerTask();
|
|
|
|
ShellTask();
|
|
|
|
ExtendBoardTask();
|
|
|
|
OperatorTask();
|
|
|
|
WorkCtrlTask();
|
|
|
|
}while(0);
|
|
|
|
ver = GetFpgaHardVersion(); // 读取硬件版本信息
|
|
|
|
if (((ver&0xff00)>>8) != FPGA_EMB_VER)
|
|
{
|
|
err = ERR_FPGA_HARD_ERR;
|
|
ReportError(err);
|
|
printf("fpga hard ver error\r\n");
|
|
}
|
|
|
|
ver = GetFpgaSoftVersion(); // 读取软件版本信息
|
|
|
|
if (ver == 0)
|
|
{
|
|
err = ERR_FPGA_ERR;
|
|
ReportError(err);
|
|
printf("fpga soft ver error\r\n");
|
|
}
|
|
|
|
if (WaitAllButtonUp() != 0) // 等待所有按键抬起
|
|
{
|
|
err = ERR_BUTTON_NOUP; // 等待按钮抬起超时
|
|
ReportError(err);
|
|
}
|
|
|
|
CleanButtonTask(); // 清除按键任务
|
|
|
|
CheckSensorAndPos(); // 检测传感器和位置
|
|
|
|
printf("PreMainLoop over\r\n");
|
|
}
|
|
|
|
#endif
|