This repository has been archived on 2025-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
controller-hd/User/app.c

81 lines
2.5 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file app.c
* @author xxx
* @date 2023-08-30 08:58:43
* @brief app初始化和app启动
* @copyright Copyright (c) 2023 by xxx, All Rights Reserved.
*/
#include "app.h"
#include "adcs.h"
uDeviceTypedef uDevice; // 设备内设置的信息
uRealTimeDef uRtData; // 实时参数
pid_t _pid; // pid参数
driver_icon_enable_u driver_icon_enable; // 驱动使能图标
volatile float32 calib_param[CALIBPARA_NUM][2]; // 校准参数
// 模拟量
volatile uint16_t adc_raw[ADC1_MAX]; // ADC原始值
volatile uint16_t ip_out; // DAC输出值
// 数字量
volatile float32 loop_current = 0; // 输入电流mA
volatile float32 actual_travel = 0; // 实际阀门位置 % (1位小数如 0~100%, 100% = 1000)
volatile float32 target_travel = 0; // 目标阀门位置 % (1位小数如 0~100%, 100% = 1000)
volatile float32 pid_target = 0; // pid控制目标
volatile float32 pid_actual = 0; // pid控制实际
volatile float32 show_loop = 0; // 显示电流
volatile float32 show_target = 0; // 显示目标
volatile float32 show_actual = 0; // 显示实际
volatile float32 target_actual_diff = 0; // 目标与实际差值 % (1位小数如 0~100%, 100% = 1000)
volatile uint8_t target_direction = 1; // 目标方向,0:向下,1:向上
volatile float32 temperature = 0; // 温度
volatile float32 pressure; // 压力kPa
volatile float32 pressureA; // A路压力
volatile float32 pressureB; // B路压力
volatile float32 range_percentage; // 量程百分比
uint8_t cpu_percent = 0; // CPU使用率
uint8_t mem_percent = 0; // 内存使用率
uint32_t mode_default_autoload; // 默认自动加载
static void app_preload(void)
{
mode_default_autoload = LL_TIM_GetAutoReload(TIM7);
if (app_preload_flag != 0xa5)
{
app_preload_flag = 0xa5;
uDevice.eLanguage = CHINESE;
app_preload_language_flag = uDevice.eLanguage;
}
else
{
uDevice.eLanguage = app_preload_language_flag;
}
}
/**
* @brief app初始化
* @return {*}
* @note
*/
void app_init()
{
app_preload();
fal_execution_init(); // fal初始化
params_init(); // 参数初始化
key_init(); // 按键初始化
flow_init(); // 流程初始化
mode_init(); // 工作模式初始化
}
/**
* @brief 业务流程启动
* @return {*}
* @note
*/
void app_start()
{
flow_start();
}