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.
155 lines
5.6 KiB
155 lines
5.6 KiB
#include <stddef.h>
|
|
#include <stdio.h>
|
|
|
|
#include "board.h"
|
|
#include "sdk\components\subcanmodule\zcancmder_subboard_initer.hpp"
|
|
/*******************************************************************************
|
|
* PROJECT_INCLUDE *
|
|
*******************************************************************************/
|
|
#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
|
|
#include "sdk\components\mini_servo_motor\feite_servo_motor.hpp"
|
|
#include "sdk\components\mini_servo_motor\mini_servo_motor_ctrl_module.hpp"
|
|
#include "sdk\components\pipette_module\pipette_ctrl_module_v2.hpp"
|
|
#include "sdk\components\sensors\m3078\m3078_code_scaner.hpp"
|
|
#include "sdk\components\tmc\ic\ztmc4361A.hpp"
|
|
#include "sdk\components\tmc\ic\ztmc5130.hpp"
|
|
//
|
|
#include "driver.hpp"
|
|
#include "sdk\components\sensors\tmp117\tmp117.hpp"
|
|
#include "sdk\components\ti\drv8710.hpp"
|
|
#include "sdk\components\water_cooling_temperature_control_module\pwm_ctrl_module.hpp"
|
|
#include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module.hpp"
|
|
#include "sdk\components\zcancmder_module\zcan_fan_ctrl_module.hpp"
|
|
|
|
#define TAG "main"
|
|
using namespace iflytop;
|
|
using namespace std;
|
|
|
|
static ZCancmderSubboardIniter initer;
|
|
|
|
extern void umain();
|
|
extern "C" {
|
|
void StartDefaultTask(void const* argument) { umain(); }
|
|
}
|
|
/*******************************************************************************
|
|
* GET_DEVICE_ID *
|
|
*******************************************************************************/
|
|
static int32_t getDeviceId() {
|
|
static bool init = false;
|
|
static ZGPIO ID0;
|
|
static ZGPIO ID1;
|
|
static ZGPIO ID2;
|
|
static ZGPIO ID3;
|
|
if (!init) {
|
|
ID0.initAsInput(ID0_IO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
|
|
ID1.initAsInput(ID1_IO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
|
|
ID2.initAsInput(ID2_IO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
|
|
ID3.initAsInput(ID3_IO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
|
|
init = true;
|
|
}
|
|
// uint8_t id = ID0.getState() * 1 + ID1.getState() * 2 + ID2.getState() * 4 + ID3.getState() * 8 + ID4.getState() * 16;
|
|
if (ID0.getState() == 0) {
|
|
return 4;
|
|
} else {
|
|
return 5;
|
|
}
|
|
}
|
|
|
|
static int32_t getPeltierNum() {
|
|
static bool init = false;
|
|
static ZGPIO ID4;
|
|
if (!init) {
|
|
ID4.initAsInput(ID4_IO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
|
|
init = true;
|
|
}
|
|
if (ID4.getState() == 0) {
|
|
return 1;
|
|
} else {
|
|
return 2;
|
|
}
|
|
}
|
|
|
|
static bool m_onefan = false;
|
|
|
|
/*******************************************************************************
|
|
* INIT_SUBMODULE *
|
|
*******************************************************************************/
|
|
void nvs_init_cb() {}
|
|
|
|
// ZIPWMFanCtrlModule* fan_ctrl;
|
|
// ZIDcMotorCtrlModule* pelter_ctrl;
|
|
// ZIPWMPumpCtrlModule* pump_ctrl;
|
|
|
|
static void initsubmodule() {
|
|
#define TIMER1_FREQ 1000
|
|
#define HEART_SHAFT false
|
|
|
|
{
|
|
static TMP117 temp[4];
|
|
static FanCtrlModule fan;
|
|
static PumpCtrlModule pump;
|
|
static PeltierCtrlModule peltier;
|
|
|
|
temp[0].initializate(&hi2c1, TMP117::ID0);
|
|
temp[1].initializate(&hi2c1, TMP117::ID1);
|
|
temp[2].initializate(&hi2c1, TMP117::ID2);
|
|
temp[3].initializate(&hi2c1, TMP117::ID3);
|
|
|
|
if (getPeltierNum() == 1) {
|
|
fan.initialize(FanCtrlModule::kfan0);
|
|
peltier.initialize(PeltierCtrlModule::kpeltier0);
|
|
} else {
|
|
fan.initialize(FanCtrlModule::kfan0and1);
|
|
peltier.initialize(PeltierCtrlModule::kpeltier0and1);
|
|
}
|
|
pump.initialize();
|
|
|
|
/*******************************************************************************
|
|
* ¿ØÎÂÄ£¿é³õʼ»¯ *
|
|
*******************************************************************************/
|
|
static WaterCoolingTemperatureControlModule waterCoolingTemperatureControlModule;
|
|
static WaterCoolingTemperatureControlModule::config_t temp_ctrl_config;
|
|
waterCoolingTemperatureControlModule.createDefaultConfig(&temp_ctrl_config);
|
|
WaterCoolingTemperatureControlModule::hardwared_config_t hardwared_config = //
|
|
{
|
|
.temperature_sensor = {&temp[0], &temp[1], &temp[2], &temp[3]},
|
|
.temp_fb_index = 0,
|
|
.fan_ctrl = &fan,
|
|
.pelter_ctrl = &peltier,
|
|
.pump_ctrl = &pump,
|
|
};
|
|
|
|
waterCoolingTemperatureControlModule.initialize(initer.get_module_id(1), &temp_ctrl_config, &hardwared_config);
|
|
initer.register_module(&waterCoolingTemperatureControlModule);
|
|
}
|
|
|
|
if (getPeltierNum() == 1) {
|
|
static FanCtrlModule fan;
|
|
static ZcanFanCtrlModule fan_ctrl_module;
|
|
fan.initialize(FanCtrlModule::kfan1);
|
|
fan_ctrl_module.initialize(initer.get_module_id(2), &fan, 50);
|
|
initer.register_module(&fan_ctrl_module);
|
|
}
|
|
}
|
|
|
|
/*******************************************************************************
|
|
* MAIN *
|
|
*******************************************************************************/
|
|
void umain() {
|
|
ZCancmderSubboardIniter::cfg_t cfg = //
|
|
{
|
|
.deviceId = getDeviceId(),
|
|
.input_gpio =
|
|
{
|
|
{PC6, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true},
|
|
{PC7, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true},
|
|
},
|
|
.output_gpio =
|
|
{
|
|
{PD0, ZGPIO::kMode_nopull, false, false},
|
|
},
|
|
};
|
|
initer.init(&cfg);
|
|
initsubmodule();
|
|
initer.loop();
|
|
}
|