diff --git a/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c b/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c
index 9ba2ba7..a791fb9 100644
--- a/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c
+++ b/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c
@@ -326,7 +326,7 @@ __weak uint32_t HAL_GetTick(void)
}
/**
- * @brief This function returns a tick priority.
+ * @brief This function returns ahiwdg tick priority.
* @retval tick priority
*/
uint32_t HAL_GetTickPrio(void)
diff --git a/a8000_temperature_ctl.launch b/a8000_temperature_ctl.launch
index 337918f..99c3033 100644
--- a/a8000_temperature_ctl.launch
+++ b/a8000_temperature_ctl.launch
@@ -51,7 +51,7 @@
-
+
diff --git a/sdk b/sdk
index a41640a..89a7ff2 160000
--- a/sdk
+++ b/sdk
@@ -1 +1 @@
-Subproject commit a41640afe9d4f8e990c13c769238e1a79940fc88
+Subproject commit 89a7ff2c9c2328ba294d19ca501c2303a0942659
diff --git a/usrc/board.h b/usrc/board.h
new file mode 100644
index 0000000..56e2cae
--- /dev/null
+++ b/usrc/board.h
@@ -0,0 +1,32 @@
+#pragma once
+// MOTOR1
+#define TMC_MOTOR_SPI hspi1
+#define TMC5130_MOTOR_NUM 1
+#define MOTOR0_CSN PA4
+#define MOTOR0_ENN PB7
+#define MOTOR1_SPI_MODE_SELECT PB4
+
+#define MOTOR_CFG_FLASH_MARK "MOTOR_CFG_FLASH_MARK"
+
+#if 0
+#define STEPPER_MOTOR_ZERO_SENSOR SENSOR_INT0
+#define STEPPER_MOTOR_FORWARD_SENSOR SENSOR_INT8
+#define STEPPER_MOTOR_BACKWARD_SENSOR SENSOR_INT9
+#endif
+
+#define ID0_IO PD11
+#define ID1_IO PD12
+#define ID2_IO PD13
+#define ID3_IO PD14
+#define ID4_IO PD15
+
+#define SENSOR_INT0 PD0
+#define SENSOR_INT1 PD1
+#define SENSOR_INT2 PD2
+#define SENSOR_INT3 PD3
+#define SENSOR_INT4 PD4
+#define SENSOR_INT5 PD5
+#define SENSOR_INT6 PD6
+#define SENSOR_INT7 PD7
+#define SENSOR_INT8 PD8
+#define SENSOR_INT9 PD9
diff --git a/usrc/driver.cpp b/usrc/driver.cpp
new file mode 100644
index 0000000..a6147d6
--- /dev/null
+++ b/usrc/driver.cpp
@@ -0,0 +1,288 @@
+#include "driver.hpp"
+using namespace iflytop;
+#define TIMER2_FREQ 1000
+#define TIMER1_FREQ 1000
+#define HEART_SHAFT false
+
+#define TAG "DRIVER"
+/*******************************************************************************
+ * 风扇配置 *
+ *******************************************************************************/
+PWMSpeedCtrlModule::config_t fan0cfg = {
+ .name = "fan0",
+ .pwm_cfg =
+ {
+ .name = "fan0pwmtimer",
+ .htim = &htim2,
+ .freq = TIMER2_FREQ,
+ .polarity = false,
+ },
+ .nfan = 2,
+ .fan0Channel = {3, 0, 0, 0},
+ .fanFBGpioCfg =
+ {
+ {.pin = PC10},
+ {.pin = PC11},
+ },
+ .fanPowerGpioCfg =
+ {
+ {
+ .pin = PC4,
+ .mode = ZGPIO::kMode_nopull,
+ .mirror = false,
+ },
+ },
+ .enablefbcheck = false,
+ .enableTrace = true,
+};
+
+PWMSpeedCtrlModule::config_t fan1cfg = {
+ .name = "fan1",
+ .pwm_cfg =
+ {
+ .name = "fan1pwmtimer",
+ .htim = &htim2,
+ .freq = TIMER2_FREQ,
+ .polarity = false,
+ },
+ .nfan = 2,
+ .fan0Channel = {4, 0, 0, 0},
+ .fanFBGpioCfg =
+ {
+ {.pin = PC12},
+ {.pin = PC13},
+ },
+ .fanPowerGpioCfg =
+ {
+ {
+ .pin = PC5,
+ .mode = ZGPIO::kMode_nopull,
+ .mirror = false,
+ },
+ },
+ .enablefbcheck = false,
+ .enableTrace = true,
+};
+
+/*******************************************************************************
+ * FanCtrlModule *
+ *******************************************************************************/
+void FanCtrlModule::initialize(fan_index_t index) {
+ m_fanindex = index;
+
+ if (m_fanindex == kfan0) {
+ fan0.initialize(&fan0cfg);
+ } else if (m_fanindex == kfan1) {
+ fan1.initialize(&fan1cfg);
+ } else if (m_fanindex == kfan0and1) {
+ fan0.initialize(&fan0cfg);
+ fan1.initialize(&fan1cfg);
+ }
+}
+
+void FanCtrlModule::setFanSpeed(int32_t duty) {
+ if (m_fanindex == kfan0) {
+ fan0.startModule(duty);
+ } else if (m_fanindex == kfan1) {
+ fan1.startModule(duty);
+ } else if (m_fanindex == kfan0and1) {
+ fan0.startModule(duty);
+ fan1.startModule(duty);
+ }
+}
+void FanCtrlModule::stop() {
+ if (m_fanindex == kfan0) {
+ fan0.stopModule();
+ } else if (m_fanindex == kfan1) {
+ fan1.stopModule();
+ } else if (m_fanindex == kfan0and1) {
+ fan0.stopModule();
+ fan1.stopModule();
+ }
+}
+
+bool FanCtrlModule::isWorking() {
+ if (m_fanindex == kfan0) {
+ return fan0.isWorking();
+ } else if (m_fanindex == kfan1) {
+ return fan1.isWorking();
+ } else if (m_fanindex == kfan0and1) {
+ return fan0.isWorking() || fan1.isWorking();
+ }
+ return false;
+}
+
+void FanCtrlModule::clearError() {
+ if (m_fanindex == kfan0) {
+ fan0.clearError();
+ } else if (m_fanindex == kfan1) {
+ fan1.clearError();
+ } else if (m_fanindex == kfan0and1) {
+ fan0.clearError();
+ fan1.clearError();
+ }
+};
+
+bool FanCtrlModule::isError() {
+ if (m_fanindex == kfan0) {
+ return fan0.isError();
+ } else if (m_fanindex == kfan1) {
+ return fan1.isError();
+ } else if (m_fanindex == kfan0and1) {
+ return fan0.isError() || fan1.isError();
+ }
+ return false;
+}
+
+/*******************************************************************************
+ * 水泵配置 *
+ *******************************************************************************/
+PWMSpeedCtrlModule::config_t pumpcfg = {
+ .name = "pump",
+ .pwm_cfg =
+ {
+ .name = "pumptime",
+ .htim = &htim2,
+ .freq = TIMER2_FREQ,
+ .polarity = false,
+ .calltrace = true,
+ },
+ .nfan = 1,
+ .fan0Channel = {2, 0, 0, 0},
+ .fanFBGpioCfg =
+ {
+ {.pin = PC3},
+ },
+ .fanPowerGpioCfg =
+ {
+ {
+ .pin = PC2,
+ .mode = ZGPIO::kMode_nopull,
+ .mirror = false,
+ .log_when_setstate = true,
+
+ },
+ },
+ .enablefbcheck = false,
+ .enableTrace = true,
+};
+
+/*******************************************************************************
+ * PumpCtrlModule *
+ *******************************************************************************/
+void PumpCtrlModule::initialize() { pump.initialize(&pumpcfg); }
+
+void PumpCtrlModule::setPumpSpeed(int32_t duty) { pump.startModule(duty); }
+void PumpCtrlModule::stop() { pump.stopModule(); }
+bool PumpCtrlModule::isError() { return pump.isError(); }
+bool PumpCtrlModule::isWorking() { return pump.isWorking(); }
+void PumpCtrlModule::clearError() { return pump.clearError(); }
+
+/*******************************************************************************
+ * 帕尔贴配置 *
+ *******************************************************************************/
+DRV8710::config_t peltier_config0 = {
+ .pwm_cfg =
+ {
+ .name = "peltier0_pwm",
+ .htim = &htim1,
+ .freq = TIMER1_FREQ,
+ .polarity = false,
+ },
+ .in1_chnannel_index = 1, // PE9
+ .in2 = PE11,
+ .nsleep = PB2,
+ .nfault = PB3,
+ .sensePin = PB4,
+ .shaft = HEART_SHAFT,
+ .enableTrace = true,
+};
+
+DRV8710::config_t peltier_config1 = {
+ .pwm_cfg =
+ {
+ .name = "peltier1_pwm",
+ .htim = &htim1,
+ .freq = TIMER1_FREQ,
+ .polarity = false,
+ },
+ .in1_chnannel_index = 3, // PE13
+ .in2 = PE14,
+ .nsleep = PB13,
+ .nfault = PB14,
+ .sensePin = PB15,
+ .shaft = HEART_SHAFT,
+ .enableTrace = true,
+};
+
+void PeltierCtrlModule::initialize(peltier_index_t index) {
+ m_index = index;
+
+ if (m_index == kpeltier0) {
+ peltier0.initialize(&peltier_config0);
+ } else if (m_index == kpeltier1) {
+ peltier1.initialize(&peltier_config1);
+ } else if (m_index == kpeltier0and1) {
+ peltier0.initialize(&peltier_config0);
+ peltier1.initialize(&peltier_config1);
+ }
+}
+
+void PeltierCtrlModule::setSpeed(int32_t duty) {
+ m_workflag = true;
+
+ if (m_index == kpeltier0) {
+ peltier0.enable(true);
+ peltier0.move(duty);
+ } else if (m_index == kpeltier1) {
+ peltier1.enable(true);
+ peltier1.move(duty);
+ } else if (m_index == kpeltier0and1) {
+ peltier0.enable(true);
+ peltier0.move(duty);
+ peltier1.enable(true);
+ peltier1.move(duty);
+ }
+}
+void PeltierCtrlModule::stop() {
+ m_workflag = false;
+
+ if (m_index == kpeltier0) {
+ peltier0.enable(false);
+ peltier0.move(0);
+ } else if (m_index == kpeltier1) {
+ peltier1.enable(false);
+ peltier1.move(0);
+ } else if (m_index == kpeltier0and1) {
+ peltier0.enable(false);
+ peltier0.move(0);
+ peltier1.enable(false);
+ peltier1.move(0);
+ }
+}
+bool PeltierCtrlModule::isError() {
+ if (m_index == kpeltier0) {
+ return peltier0.isFault();
+ } else if (m_index == kpeltier1) {
+ return peltier1.isFault();
+ } else if (m_index == kpeltier0and1) {
+ return peltier0.isFault() || peltier1.isFault();
+ }
+ return false;
+}
+
+bool PeltierCtrlModule::dumpErrorInfo() { //
+ if (m_index == kpeltier0) {
+ ZLOGI(TAG, "motor0 fault:%d,sense:%d", !peltier0.isFault(), peltier0.getSensePinState());
+ } else if (m_index == kpeltier1) {
+ ZLOGI(TAG, "motor1 fault:%d,sense:%d", !peltier1.isFault(), peltier1.getSensePinState());
+ } else if (m_index == kpeltier0and1) {
+ ZLOGI(TAG, "motor0 fault:%d,sense:%d", !peltier0.isFault(), peltier0.getSensePinState());
+ ZLOGI(TAG, "motor1 fault:%d,sense:%d", !peltier1.isFault(), peltier1.getSensePinState());
+ }
+ return true;
+};
+
+bool PeltierCtrlModule::isWorking() { return m_workflag; }
+
+void PeltierCtrlModule::clearError() { return; }
\ No newline at end of file
diff --git a/usrc/driver.hpp b/usrc/driver.hpp
new file mode 100644
index 0000000..ec88e44
--- /dev/null
+++ b/usrc/driver.hpp
@@ -0,0 +1,97 @@
+#pragma once
+#include
+#include
+
+#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 "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"
+
+namespace iflytop {
+
+class FanCtrlModule : public ZIPWMFanCtrlModule {
+ public:
+ typedef enum {
+ kfan0,
+ kfan1,
+ kfan0and1,
+ } fan_index_t;
+
+ private:
+ /* data */
+ PWMSpeedCtrlModule fan0;
+ PWMSpeedCtrlModule fan1;
+
+ fan_index_t m_fanindex = kfan0and1;
+
+ public:
+ void initialize(fan_index_t index);
+
+ virtual void setFanSpeed(int32_t duty) override;
+ virtual void stop() override;
+
+ virtual bool isWorking() override;
+
+ virtual bool isError() override;
+ virtual void clearError() override;
+};
+
+class PumpCtrlModule : public ZIPWMPumpCtrlModule {
+ private:
+ /* data */
+ PWMSpeedCtrlModule pump;
+
+ public:
+ void initialize();
+
+ virtual void setPumpSpeed(int32_t duty) override;
+ virtual void stop() override;
+
+ virtual bool isWorking() override;
+
+ virtual bool isError() override;
+ virtual void clearError() override;
+};
+
+class PeltierCtrlModule : public ZIDcMotorCtrlModule {
+ public:
+ typedef enum {
+ kpeltier0,
+ kpeltier1,
+ kpeltier0and1,
+ } peltier_index_t;
+
+ private:
+ /* data */
+ DRV8710 peltier0;
+ DRV8710 peltier1;
+ bool m_workflag = false;
+ peltier_index_t m_index;
+
+ public:
+ void initialize(peltier_index_t index);
+
+ virtual void setSpeed(int32_t duty) override;
+ virtual void stop() override;
+ virtual bool isWorking() override;
+
+ virtual bool dumpErrorInfo() override;
+
+ virtual bool isError() override;
+ virtual void clearError() override;
+};
+
+} // namespace iflytop
\ No newline at end of file
diff --git a/usrc/main.cpp b/usrc/main.cpp
index 94c0a14..5b57fad 100644
--- a/usrc/main.cpp
+++ b/usrc/main.cpp
@@ -1,243 +1,109 @@
#include
#include
-#include "sdk/os/zos.hpp"
-#include "sdk\components\flash\zsimple_flash.hpp"
-#include "sdk\components\zcancmder\zcanreceiver.hpp"
-#include "sdk\components\zcancmder_module\zcan_basic_order_module.hpp"
-//
-#include "sdk\components\flash\znvs.hpp"
+#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\water_cooling_temperature_control_module\water_cooling_temperature_control_module_factory.cpp"
-#include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module_factory.hpp"
+#include "sdk\components\zcancmder_module\zcan_fan_ctrl_module.hpp"
-// cancmder basic
-#include "sdk\components\cmdscheduler\cmd_scheduler_v2.hpp"
-#include "sdk\components\hardware\uart\zuart_dma_receiver.hpp"
-#include "sdk\components\zcancmder\zcan_board_module.hpp"
-#include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
-#include "sdk\components\zprotocols\zcancmder_v2\protocol_parser.hpp"
-#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
-//
#define TAG "main"
using namespace iflytop;
using namespace std;
+static ZCancmderSubboardIniter initer;
+
extern void umain();
extern "C" {
void StartDefaultTask(void const* argument) { umain(); }
}
-
-// static ZCanCmder g_zcanCmder;
-// static ZIProtocolParser g_ziProtocolParser;
-
-static ZCanCmder g_zcanCmder;
-static ZIProtocolParser g_ziProtocolParser;
-static ZModuleDeviceManager g_zModuleDeviceManager;
-static MicroComputerModuleDeviceScriptCmderPaser g_zModuleDeviceScriptCmderPaser;
-static uint32_t g_deviceId = 0;
-
-uint8_t getId() {
+/*******************************************************************************
+ * GET_DEVICE_ID *
+ *******************************************************************************/
+static int32_t getDeviceId() {
static bool init = false;
static ZGPIO ID0;
static ZGPIO ID1;
static ZGPIO ID2;
static ZGPIO ID3;
- static ZGPIO ID4;
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);
- ID4.initAsInput(ID4_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;
- return id;
+ // 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;
+ }
}
-void initcfg() {
-/**
- * @brief 初始化配置,系统中需要配置都需要在这里进行初始化
- */
-#if 0
- static I_StepMotorCtrlModule::flash_config_t cfg;
- StepMotorCtrlModule::create_default_cfg(cfg);
- ZNVS::ins().alloc_config(MOTOR_CFG_FLASH_MARK, (uint8_t*)&cfg, sizeof(cfg));
-#endif
+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;
+ }
}
-void initmodule() {
-#define TIMER2_FREQ 1000
-#define TIMER1_FREQ 1000
-#define HEART_SHAFT false
- /*******************************************************************************
- * 风扇配置 *
- *******************************************************************************/
- PWMSpeedCtrlModule::config_t fan0cfg = {
- .name = "fan0",
- .pwm_cfg =
- {
- .name = "fan0pwmtimer",
- .htim = &htim2,
- .freq = TIMER2_FREQ,
- .polarity = false,
- },
- .nfan = 2,
- .fan0Channel = {3, 0, 0, 0},
- .fanFBGpioCfg =
- {
- {.pin = PC10},
- {.pin = PC11},
- },
- .fanPowerGpioCfg =
- {
- {
- .pin = PC4,
- .mode = ZGPIO::kMode_nopull,
- .mirror = false,
- },
- },
- .enablefbcheck = false,
- .enableTrace = true,
- };
- PWMSpeedCtrlModule::config_t fan1cfg = {
- .name = "fan1",
- .pwm_cfg =
- {
- .name = "fan1pwmtimer",
- .htim = &htim2,
- .freq = TIMER2_FREQ,
- .polarity = false,
- },
- .nfan = 2,
- .fan0Channel = {4, 0, 0, 0},
- .fanFBGpioCfg =
- {
- {.pin = PC12},
- {.pin = PC13},
- },
- .fanPowerGpioCfg =
- {
- {
- .pin = PC5,
- .mode = ZGPIO::kMode_nopull,
- .mirror = false,
- },
- },
- .enablefbcheck = false,
- .enableTrace = true,
- };
+static bool m_onefan = false;
- /*******************************************************************************
- * 水泵配置 *
- *******************************************************************************/
- PWMSpeedCtrlModule::config_t pumpcfg = {
- .name = "pump",
- .pwm_cfg =
- {
- .name = "pumptime",
- .htim = &htim2,
- .freq = TIMER2_FREQ,
- .polarity = false,
- .calltrace = true,
- },
- .nfan = 1,
- .fan0Channel = {2, 0, 0, 0},
- .fanFBGpioCfg =
- {
- {.pin = PC3},
- },
- .fanPowerGpioCfg =
- {
- {
- .pin = PC2,
- .mode = ZGPIO::kMode_nopull,
- .mirror = false,
- .log_when_setstate = true,
+/*******************************************************************************
+ * INIT_SUBMODULE *
+ *******************************************************************************/
+void nvs_init_cb() {}
- },
- },
- .enablefbcheck = false,
- .enableTrace = true,
- };
+// ZIPWMFanCtrlModule* fan_ctrl;
+// ZIDcMotorCtrlModule* pelter_ctrl;
+// ZIPWMPumpCtrlModule* pump_ctrl;
- DRV8710::config_t peltier_config0 = {
- .pwm_cfg =
- {
- .name = "peltier0_pwm",
- .htim = &htim1,
- .freq = TIMER1_FREQ,
- .polarity = true,
- },
- .in1_chnannel_index = 1, // PE9
- .in2 = PE11,
- .nsleep = PB2,
- .nfault = PB3,
- .shaft = HEART_SHAFT,
- .enableTrace = true,
- };
-
- DRV8710::config_t peltier_config1 = {
- .pwm_cfg =
- {
- .name = "peltier1_pwm",
- .htim = &htim1,
- .freq = TIMER1_FREQ,
- .polarity = true,
- },
- .in1_chnannel_index = 3, // PE13
- .in2 = PE14,
- .nsleep = PB13,
- .nfault = PB14,
- .shaft = HEART_SHAFT,
- .enableTrace = true,
- };
-
- static TMP117 temp[4];
- static PWMSpeedCtrlModule fan0;
- static PWMSpeedCtrlModule fan1;
- static PWMSpeedCtrlModule pump;
- static DRV8710 peltier0;
- static DRV8710 peltier1;
-
- temp[0].initializate(&hi2c1, TMP117::ID0);
- temp[1].initializate(&hi2c1, TMP117::ID1);
- temp[2].initializate(&hi2c1, TMP117::ID2);
- temp[3].initializate(&hi2c1, TMP117::ID3);
-
- fan0.initialize(&fan0cfg);
- fan1.initialize(&fan1cfg);
- pump.initialize(&pumpcfg);
- peltier0.initialize(&peltier_config0);
- peltier1.initialize(&peltier_config1);
+static void initsubmodule() {
+#define TIMER1_FREQ 1000
+#define HEART_SHAFT false
{
- /**
- * @brief 板子本身模块初始化
- */
- static ZCanBoardModule::hardware_config_t cfg = {
- .input =
- {
- {PC6, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true},
- {PC7, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true},
- },
- .output =
- {
- {PD0, ZGPIO::kMode_nopull, false, false},
- } //
- };
- static ZCanBoardModule boardmodule;
- boardmodule.initialize(g_deviceId, &cfg);
- g_ziProtocolParser.registerModule(&boardmodule);
- g_zModuleDeviceManager.registerModule(&boardmodule);
- }
+ 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();
- {
/*******************************************************************************
* 控温模块初始化 *
*******************************************************************************/
@@ -247,59 +113,43 @@ void initmodule() {
WaterCoolingTemperatureControlModule::hardwared_config_t hardwared_config = //
{
.temperature_sensor = {&temp[0], &temp[1], &temp[2], &temp[3]},
- .fanTable = {&fan0, &fan1},
- .pump = &pump,
- .peltier_ctrl = {&peltier0, &peltier1},
+ .temp_fb_index = 1,
+ .fan_ctrl = &fan,
+ .pelter_ctrl = &peltier,
+ .pump_ctrl = &pump,
};
- waterCoolingTemperatureControlModule.initialize(g_deviceId + 1, &temp_ctrl_config, &hardwared_config);
- g_zModuleDeviceManager.registerModule(&waterCoolingTemperatureControlModule);
- g_ziProtocolParser.registerModule(&waterCoolingTemperatureControlModule);
+ waterCoolingTemperatureControlModule.initialize(initer.get_module_id(1), &temp_ctrl_config, &hardwared_config);
+ initer.register_module(&waterCoolingTemperatureControlModule);
}
-}
-void umain() {
- chip_cfg_t chipcfg;
- chipcfg.us_dleay_tim = &DELAY_US_TIMER;
- chipcfg.tim_irq_scheduler_tim = &TIM_IRQ_SCHEDULER_TIMER;
- chipcfg.huart = &DEBUG_UART;
- chipcfg.debuglight = DEBUG_LIGHT_GPIO;
-
- chip_init(&chipcfg);
-
- zos_cfg_t zoscfg;
- zos_init(&zoscfg);
- g_deviceId = getId() * 10;
- ZLOGI(TAG, "motorId:%d", g_deviceId);
-
- /*******************************************************************************
- * NVSINIT *
- *******************************************************************************/
- ZNVS::ins().initialize(IFLYTOP_NVS_CONFIG_FLASH_SECTOR);
- initcfg();
- ZNVS::ins().init_config();
-
- auto zcanCmder_cfg = g_zcanCmder.createCFG(g_deviceId);
- g_zcanCmder.init(zcanCmder_cfg);
- g_ziProtocolParser.initialize(&g_zcanCmder);
-
- static ZUARTDmaReceiver dmaUartReceiver;
- static CmdSchedulerV2 cmder;
- ZUARTDmaReceiver::hardware_config_t cfg = {
- .huart = &DEBUG_UART,
- .dma_rx = &DEBUG_UART_DMA,
- .rxbuffersize = 1024,
- .rxovertime_ms = 10,
- };
- dmaUartReceiver.initialize(&cfg);
- cmder.initialize(&dmaUartReceiver);
- g_zModuleDeviceManager.initialize(nullptr);
- g_zModuleDeviceScriptCmderPaser.initialize(&cmder, &g_zModuleDeviceManager);
-
- initmodule();
- while (true) {
- OSDefaultSchduler::getInstance()->loop();
- g_zcanCmder.loop();
- cmder.schedule();
+ 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();
+}
diff --git a/usrc/project_configs.h b/usrc/project_configs.h
index 6f258e1..30f18a0 100644
--- a/usrc/project_configs.h
+++ b/usrc/project_configs.h
@@ -1,51 +1,21 @@
#pragma once
+#pragma once
+#define PC_VERSION "v1.0.1"
+#define PC_MANUFACTURER "http://www.iflytop.com/"
+#define PC_PROJECT_NAME "a8000_temperature_ctrl"
+#define PC_IFLYTOP_ENABLE_OS 1
-#define VERSION "v1.0.0"
-#define MANUFACTURER "http://www.iflytop.com/"
-#define PROJECT_NAME "a8000_temperature_ctrl"
-#define DEBUG_UART huart1
-#define DEBUG_UART_DMA hdma_usart1_rx
-#define DEBUG_LIGHT_GPIO PE2
-
-#define DELAY_US_TIMER htim6 // US延时定时器
-#define TIM_IRQ_SCHEDULER_TIMER htim7 // 中断定时器中断调度器
-#define IFLTYOP_ZTICKET_TIMER TIM11 // 系统ticket定时器
-
-#define IFLYTOP_ENABLE_OS 1
-#define IFLYTOP_PREEMPTPRIORITY_DEFAULT 5
-
-/****************************************FLASH***************************************/
-#define IFLYTOP_NVS_CONFIG_FLASH_SECTOR 8
-/*********************************************************************************/
-
-// MOTOR1
-#define TMC_MOTOR_SPI hspi1
-#define TMC5130_MOTOR_NUM 1
-#define MOTOR0_CSN PA4
-#define MOTOR0_ENN PB7
-#define MOTOR1_SPI_MODE_SELECT PB4
+#define PC_DEBUG_UART huart1
+#define PC_DEBUG_UART_DMA_HANDLER hdma_usart1_rx
+#define PC_DEBUG_UART_RX_BUF_SIZE 1024
+#define PC_DEBUG_LIGHT_GPIO PE2
-#define MOTOR_CFG_FLASH_MARK "MOTOR_CFG_FLASH_MARK"
+#define PC_SYS_DELAY_US_TIMER htim6 // US延时定时器
+#define PC_SYS_ZTICKET_TIMER TIM11 // 系统ticket定时器
+#define PC_SYS_TIM_IRQ_SCHEDULER_TIMER htim7 // 中断定时器中断调度器
-#if 0
-#define STEPPER_MOTOR_ZERO_SENSOR SENSOR_INT0
-#define STEPPER_MOTOR_FORWARD_SENSOR SENSOR_INT8
-#define STEPPER_MOTOR_BACKWARD_SENSOR SENSOR_INT9
-#endif
+#define PC_IRQ_PREEMPTPRIORITY_DEFAULT 5
-#define ID0_IO PD11
-#define ID1_IO PD12
-#define ID2_IO PD13
-#define ID3_IO PD14
-#define ID4_IO PD15
+#define PC_NVS_ENABLE 1
+#define PC_NVS_CONFIG_FLASH_SECTOR 8
-#define SENSOR_INT0 PD0
-#define SENSOR_INT1 PD1
-#define SENSOR_INT2 PD2
-#define SENSOR_INT3 PD3
-#define SENSOR_INT4 PD4
-#define SENSOR_INT5 PD5
-#define SENSOR_INT6 PD6
-#define SENSOR_INT7 PD7
-#define SENSOR_INT8 PD8
-#define SENSOR_INT9 PD9