141 lines
2.7 KiB
C
141 lines
2.7 KiB
C
|
|
#include "FreeRTOS.h"
|
|
#include "task.h"
|
|
#include "main.h"
|
|
#include "main_task.h"
|
|
#include "device_task.h"
|
|
#include "monitor_task.h"
|
|
#include "global.h"
|
|
|
|
#include "control.h"
|
|
|
|
|
|
#include "drv_relay.h"
|
|
#include "drv_fan.h"
|
|
#include "drv_power.h"
|
|
|
|
//osThreadId cliTaskHandle;
|
|
//osThreadId displayTaskHandle;
|
|
//osThreadId touchTaskHandle;
|
|
//osThreadId monitorTaskHandle;
|
|
//osThreadId deviceTaskHandle;
|
|
|
|
|
|
osThreadId_t cilTaskHandle;
|
|
const osThreadAttr_t cilTask_attributes = {
|
|
.name = "cilTask",
|
|
.priority = (osPriority_t) osPriorityNormal,
|
|
.stack_size = 128 * 4
|
|
};
|
|
|
|
osThreadId_t monitorTaskHandle;
|
|
const osThreadAttr_t monitorTask_attributes = {
|
|
.name = "monitorTask",
|
|
.priority = (osPriority_t) osPriorityNormal,
|
|
.stack_size = 1024 * 4
|
|
};
|
|
|
|
osThreadId_t deviceTaskHandle;
|
|
const osThreadAttr_t deviceTask_attributes = {
|
|
.name = "deviceTask",
|
|
.priority = (osPriority_t) osPriorityNormal,
|
|
.stack_size = 128 * 4
|
|
};
|
|
|
|
extern void StartCliTask(void * argument);
|
|
extern void StartMonitorTask(void * argument);
|
|
extern void StartDeviceTask(void * argument);
|
|
|
|
|
|
|
|
void StartDefaultTask(void * argument)
|
|
{
|
|
uint16_t tick = 0;
|
|
|
|
//task init
|
|
cilTaskHandle = osThreadNew(StartCliTask, NULL, &cilTask_attributes);
|
|
monitorTaskHandle = osThreadNew(StartMonitorTask, NULL, &monitorTask_attributes);
|
|
deviceTaskHandle = osThreadNew(StartDeviceTask, NULL, &deviceTask_attributes);
|
|
|
|
|
|
//init
|
|
|
|
control_initialize();
|
|
|
|
control_U.mode = 0;
|
|
control_U.bat_type = 0;
|
|
control_U.bat_num = 6;
|
|
control_U.run_state = 0;
|
|
control_U.cmd_current = 1;
|
|
control_U.bat_capacity = 10000;
|
|
|
|
for(;;)
|
|
{
|
|
osDelay(10);
|
|
|
|
//执行电压控制,电流控制工作
|
|
//接口设置
|
|
|
|
|
|
control_U.sens_pwr_voltage = voltage_pwr;
|
|
control_U.sens_bat_voltage = voltage_bat;
|
|
control_U.sens_buck_in_voltage = voltage_buck_in;
|
|
control_U.sens_buck_out_voltage = voltage_buck_out;
|
|
control_U.sens_bat_current = voltage_current;
|
|
control_U.sens_temperature = voltage_temp;
|
|
|
|
for(int i =0;i<24;i++)
|
|
{
|
|
control_U.sens_bat_sv[i] = voltage_bat_sv[i];
|
|
}
|
|
|
|
control_U.mode = mode;
|
|
control_U.bat_type = bat_type;
|
|
control_U.bat_num = bat_num;
|
|
control_U.run_state = run_state;
|
|
control_U.cmd_current = cmd_current;
|
|
control_U.bat_capacity = bat_capacity;
|
|
|
|
//step
|
|
control_step();
|
|
|
|
|
|
//out
|
|
if(NormalTestMode == 0)
|
|
{
|
|
power_set(control_Y.out.power);
|
|
|
|
relay_set(0,control_Y.out.relay_in);
|
|
relay_set(1,control_Y.out.relay_out);
|
|
|
|
fan_set(control_Y.out.fan);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|