12 changed files with 233 additions and 159 deletions
-
4.settings/language.settings.xml
-
2Core/Inc/stm32f4xx_it.h
-
3Core/Inc/usart.h
-
7Core/Src/dma.c
-
1Core/Src/main.c
-
30Core/Src/stm32f4xx_it.c
-
44Core/Src/usart.c
-
28a8000_cliptip_module.ioc
-
2sdk
-
12usrc/board.h
-
207usrc/main.cpp
-
52usrc/project_configs.h
@ -1 +1 @@ |
|||
Subproject commit af685a17a8fd229ca4773a9c62949db89369c55f |
|||
Subproject commit fbe10eeb6c72a4419f1e05c745bca2b7518e54e8 |
@ -0,0 +1,12 @@ |
|||
#pragma once |
|||
|
|||
// MOTOR1 |
|||
#define TMC_MOTOR_SPI hspi1 |
|||
#define TMC5130_MOTOR_NUM 1 |
|||
#define MOTOR0_CSN PA4 |
|||
#define MOTOR0_ENN PD0 |
|||
#define MOTOR1_SPI_MODE_SELECT PinNull |
|||
|
|||
#define MOTOR_CFG_FLASH_MARK "MOTOR_CFG_FLASH_MARK" |
|||
|
|||
#define BOARD_ID 2 |
@ -1,142 +1,121 @@ |
|||
#include <stddef.h>
|
|||
#include <stdio.h>
|
|||
|
|||
#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\zprotocols\zcancmder_v2\protocol_parser.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\sensors\tmp117\tmp117.hpp"
|
|||
#include "sdk\components\ti\drv8710.hpp"
|
|||
#include "sdk\components\tmc\ic\ztmc4361A.hpp"
|
|||
#include "sdk\components\tmc\ic\ztmc5130.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 "M3078CodeScanner"
|
|||
|
|||
#define TAG "main"
|
|||
using namespace iflytop; |
|||
using namespace std; |
|||
|
|||
static ZCancmderSubboardIniter initer; |
|||
|
|||
extern void umain(); |
|||
extern "C" { |
|||
void StartDefaultTask(void const* argument) { umain(); } |
|||
} |
|||
extern "C" { |
|||
extern DMA_HandleTypeDef hdma_usart2_rx; |
|||
extern DMA_HandleTypeDef hdma_usart2_tx; |
|||
} |
|||
static ZCanCmder g_zcanCmder; |
|||
static ZIProtocolParser g_ziProtocolParser; |
|||
//
|
|||
static TMC5130 g_motor; |
|||
static StepMotorCtrlModule g_stepMotorCtrlModule; |
|||
//
|
|||
static PipetteModule g_pipetteModule; |
|||
// USART4_TX
|
|||
|
|||
void init_and_reg_motor() { |
|||
/*******************************************************************************
|
|||
* GET_DEVICE_ID * |
|||
*******************************************************************************/ |
|||
static int32_t getDeviceId() { return BOARD_ID; } |
|||
/*******************************************************************************
|
|||
* INIT_SUBMODULE * |
|||
*******************************************************************************/ |
|||
void nvs_init_cb() {} |
|||
static void initsubmodule() { |
|||
osDelay(1000); |
|||
{ |
|||
TMC5130::cfg_t cfg = { |
|||
.spi = &TMC_MOTOR_SPI, //
|
|||
.csgpio = MOTOR0_CSN, //
|
|||
.ennPin = MOTOR0_ENN, //
|
|||
.spi_mode_select = MOTOR1_SPI_MODE_SELECT, //
|
|||
static TMC5130 g_motor; |
|||
static StepMotorCtrlModule g_stepMotorCtrlModule; |
|||
TMC5130::cfg_t cfg = { |
|||
.spi = &TMC_MOTOR_SPI, //
|
|||
.csgpio = MOTOR0_CSN, //
|
|||
.ennPin = MOTOR0_ENN, //
|
|||
.spi_mode_select = MOTOR1_SPI_MODE_SELECT, //
|
|||
}; |
|||
g_motor.initialize(&cfg); |
|||
g_motor.setMotorShaft(false); |
|||
ZLOGI(TAG, "motora initialize 5160:%x ", g_motor.readICVersion()); |
|||
} |
|||
|
|||
g_motor.setAcceleration(100); |
|||
g_motor.setDeceleration(100); |
|||
g_motor.setIHOLD_IRUN(0, 8, 10); |
|||
|
|||
static ZGPIO input[10]; |
|||
input[0].initAsInput(PD1 /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|||
input[1].initAsInput(PD2 /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|||
input[2].initAsInput(PD3 /*DIAG0*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|||
input[3].initAsInput(PD4 /*DIAG1*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|||
|
|||
g_stepMotorCtrlModule.initialize(BOARD_ID * 10 + 1, &g_motor, input, ZARRAY_SIZE(input), MOTOR_CFG_FLASH_MARK); |
|||
g_ziProtocolParser.registerModule(&g_stepMotorCtrlModule); |
|||
} |
|||
|
|||
void init_and_reg_cliptip_module() { |
|||
// # RS232输出压力流
|
|||
// /1U2!0R\r
|
|||
// # 设置移液枪最大行程100,防止设备误操作导致吸入液体到设备中
|
|||
// /1u1,100R\r
|
|||
PipetteModule::config_t cfg = { |
|||
.limit_ul = 100, |
|||
}; |
|||
|
|||
PipetteModule::hardward_config_t hardwarecfg = { |
|||
.uart = &huart2, |
|||
.hdma_rx = &hdma_usart2_rx, |
|||
.hdma_tx = &hdma_usart2_tx, |
|||
}; |
|||
g_pipetteModule.initialize(BOARD_ID * 10 + 2, &cfg, &hardwarecfg); |
|||
g_ziProtocolParser.registerModule(&g_pipetteModule); |
|||
} |
|||
|
|||
void init_and_reg_m3078() { //
|
|||
static M3078CodeScanner codescanner; |
|||
static M3078CodeScanner::hardware_config_t cfg = { |
|||
.uart = &huart2, |
|||
.hdma_rx = nullptr, |
|||
.hdma_tx = nullptr, |
|||
|
|||
.codeReadOkPin = PinNull, |
|||
.rstPin = PinNull, |
|||
.triggerPin = PD15, |
|||
}; |
|||
codescanner.initialize(BOARD_ID * 10 + 3, &cfg); |
|||
g_ziProtocolParser.registerModule(&codescanner); |
|||
} |
|||
|
|||
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); |
|||
g_motor.setMotorShaft(false); |
|||
g_motor.setAcceleration(100); |
|||
g_motor.setDeceleration(100); |
|||
g_motor.setIHOLD_IRUN(0, 8, 10); |
|||
|
|||
static ZGPIO input[10]; |
|||
input[0].initAsInput(PD1 /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|||
input[1].initAsInput(PD2 /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|||
input[2].initAsInput(PD3 /*DIAG0*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|||
input[3].initAsInput(PD4 /*DIAG1*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); |
|||
|
|||
I_StepMotorCtrlModule::flash_config_t smcm_cfg = {0}; |
|||
StepMotorCtrlModule::create_default_cfg(smcm_cfg); |
|||
smcm_cfg.base_param.distance_scale = 100; |
|||
smcm_cfg.base_param.distance_scale_denominator = 1; |
|||
smcm_cfg.base_param.ihold = 1; |
|||
smcm_cfg.base_param.irun = 8; |
|||
smcm_cfg.base_param.x_shaft = true; |
|||
smcm_cfg.base_param.maxspeed = 300; |
|||
smcm_cfg.base_param.run_to_zero_speed = 50; |
|||
smcm_cfg.base_param.max_x = 0; |
|||
smcm_cfg.base_param.min_x = 0; |
|||
|
|||
g_stepMotorCtrlModule.initialize(initer.get_module_id(1), &g_motor, input, ZARRAY_SIZE(input), nullptr, &smcm_cfg); |
|||
initer.register_module(&g_stepMotorCtrlModule); |
|||
} |
|||
|
|||
zos_cfg_t zoscfg; |
|||
zos_init(&zoscfg); |
|||
{ |
|||
static PipetteModule g_pipetteModule; |
|||
PipetteModule::config_t cfg = { |
|||
.limit_ul = 100, |
|||
}; |
|||
|
|||
ZLOGI(TAG, "boardId:%d", BOARD_ID); |
|||
PipetteModule::hardward_config_t hardwarecfg = { |
|||
.uart = &huart2, |
|||
.hdma_rx = &hdma_usart2_rx, |
|||
.hdma_tx = &hdma_usart2_tx, |
|||
}; |
|||
g_pipetteModule.initialize(initer.get_module_id(2), &cfg, &hardwarecfg); |
|||
initer.register_module(&g_pipetteModule); |
|||
} |
|||
|
|||
/*******************************************************************************
|
|||
* NVSINIT * |
|||
*******************************************************************************/ |
|||
ZNVS::ins().initialize(IFLYTOP_NVS_CONFIG_FLASH_SECTOR); |
|||
{ |
|||
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)); |
|||
//
|
|||
static M3078CodeScanner codescanner; |
|||
static M3078CodeScanner::hardware_config_t cfg = { |
|||
.uart = &huart2, |
|||
.hdma_rx = nullptr, |
|||
.hdma_tx = nullptr, |
|||
|
|||
.codeReadOkPin = PinNull, |
|||
.rstPin = PinNull, |
|||
.triggerPin = PD15, |
|||
}; |
|||
codescanner.initialize(initer.get_module_id(3), &cfg); |
|||
initer.register_module(&codescanner); |
|||
} |
|||
ZNVS::ins().init_config(); |
|||
auto zcanCmder_cfg = g_zcanCmder.createCFG(BOARD_ID); |
|||
g_zcanCmder.init(zcanCmder_cfg); |
|||
g_ziProtocolParser.initialize(&g_zcanCmder); |
|||
|
|||
init_and_reg_motor(); |
|||
init_and_reg_cliptip_module(); |
|||
init_and_reg_m3078(); |
|||
} |
|||
|
|||
while (true) { |
|||
OSDefaultSchduler::getInstance()->loop(); |
|||
g_zcanCmder.loop(); |
|||
} |
|||
}; |
|||
/*******************************************************************************
|
|||
* MAIN * |
|||
*******************************************************************************/ |
|||
void umain() { |
|||
ZCancmderSubboardIniter::cfg_t cfg = //
|
|||
{ |
|||
.deviceId = getDeviceId(), |
|||
.input_gpio = {}, |
|||
.output_gpio = {}, |
|||
}; |
|||
initer.init(&cfg); |
|||
initsubmodule(); |
|||
initer.loop(); |
|||
} |
@ -1,43 +1,21 @@ |
|||
#pragma once |
|||
#define PC_VERSION "v1.0.1" |
|||
#define PC_MANUFACTURER "http://www.iflytop.com/" |
|||
#define PC_PROJECT_NAME "a8000_cliptip_module" |
|||
#define PC_IFLYTOP_ENABLE_OS 1 |
|||
|
|||
#define VERSION "v1.0.0" |
|||
#define MANUFACTURER "http://www.iflytop.com/" |
|||
#define PROJECT_NAME "a8000_cliptip_module" |
|||
#define DEBUG_UART huart1 |
|||
#define DEBUG_LIGHT_GPIO PE2 |
|||
#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 DELAY_US_TIMER htim6 // US延时定时器 |
|||
#define TIM_IRQ_SCHEDULER_TIMER htim7 // 中断定时器中断调度器 |
|||
#define IFLTYOP_ZTICKET_TIMER TIM11 // 系统ticket定时器 |
|||
#define PC_SYS_DELAY_US_TIMER htim6 // US延时定时器 |
|||
#define PC_SYS_ZTICKET_TIMER TIM11 // 系统ticket定时器 |
|||
#define PC_SYS_TIM_IRQ_SCHEDULER_TIMER htim7 // 中断定时器中断调度器 |
|||
|
|||
#define IFLYTOP_ENABLE_OS 1 |
|||
#define IFLYTOP_PREEMPTPRIORITY_DEFAULT 5 |
|||
#define PC_IRQ_PREEMPTPRIORITY_DEFAULT 5 |
|||
|
|||
#define PC_NVS_ENABLE 1 |
|||
#define PC_NVS_CONFIG_FLASH_SECTOR 8 |
|||
|
|||
/****************************************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 PD0 |
|||
#define MOTOR1_SPI_MODE_SELECT PinNull |
|||
|
|||
#define MOTOR_CFG_FLASH_MARK "MOTOR_CFG_FLASH_MARK" |
|||
|
|||
#define BOARD_ID 2 |
|||
|
|||
#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 BOARD_ID 8 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue