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.
142 lines
4.7 KiB
142 lines
4.7 KiB
#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 "sdk/components/step_motor_ctrl_module/step_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\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;
|
|
|
|
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() {
|
|
osDelay(1000);
|
|
{
|
|
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);
|
|
|
|
zos_cfg_t zoscfg;
|
|
zos_init(&zoscfg);
|
|
|
|
ZLOGI(TAG, "boardId:%d", BOARD_ID);
|
|
|
|
/*******************************************************************************
|
|
* 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));
|
|
}
|
|
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();
|
|
}
|
|
};
|