8 changed files with 536 additions and 299 deletions
-
2Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c
-
2a8000_temperature_ctl.launch
-
2sdk
-
32usrc/board.h
-
288usrc/driver.cpp
-
97usrc/driver.hpp
-
352usrc/main.cpp
-
60usrc/project_configs.h
@ -1 +1 @@ |
|||
Subproject commit a41640afe9d4f8e990c13c769238e1a79940fc88 |
|||
Subproject commit 89a7ff2c9c2328ba294d19ca501c2303a0942659 |
@ -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 |
@ -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; } |
@ -0,0 +1,97 @@ |
|||
#pragma once
|
|||
#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 "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
|
@ -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 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue