Browse Source

update

master
zhaohe 2 years ago
parent
commit
eacdf47799
  1. 2
      sdk
  2. 47
      usrc/main.cpp
  3. 1
      usrc/project.hpp

2
sdk

@ -1 +1 @@
Subproject commit 43beaedd3e6c3b1b45cd8796e496902c03699a28
Subproject commit 62f322c59d64e4d8ff4795173a885a320813cd6b

47
usrc/main.cpp

@ -10,6 +10,7 @@
// #include "sdk/components/single_axis_motor_control_v2/single_axis_motor_control_v2.hpp"
#include "sdk/components/single_axis_motor_control/single_axis_motor_control.hpp"
#include "sdk/hal/zhal.hpp"
#include "sdk\components\iflytop_can_slave_modules\io_control_service.hpp"
#include "sdk\components\iflytop_can_slave_v1\iflytop_can_slave.hpp"
#include "sdk\components\tmc\ic\ztmc4361A.hpp"
#include "sdk\components\tmc\ic\ztmc5130.hpp"
@ -46,6 +47,7 @@ ZGPIO io_fybjl_sensor1;
ZGPIO io_fybjl_sensor0;
DeviceBaseControlService m_deviceBaseControlService;
IOControlService m_ioControlService;
SingleAxisMotorControler m_pyMotorControlService; // 平移电机
SingleAxisMotorControler m_tjMotorControlService; // 推进电机
OneDimensionalCodeLaserScanner m_oneDimensionalCodeLaserScanner;
@ -68,27 +70,7 @@ void input_sensors_init() {
io_fybjl_sensor1.initAsInput(FYBJL_SENSOR1, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true /*mirror*/);
io_fybjl_sensor0.initAsInput(FYBJL_SENSOR0, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true /*mirror*/);
}
uint32_t intput_sensors_get_table0() {
uint32_t val = 0;
val |= io_fybjl_sensor0.getStateUint32() << 0;
val |= io_fybjl_sensor1.getStateUint32() << 1;
val |= io_fybjl_sensor2.getStateUint32() << 2;
val |= io_fybjl_sensor3.getStateUint32() << 3;
val |= io_fybjl_sensor4.getStateUint32() << 4;
val |= io_fybjl_sensor5.getStateUint32() << 5;
val |= io_fybjl_sensor6.getStateUint32() << 6;
val |= io_fybjl_sensor7.getStateUint32() << 7;
val |= io_fybjl_sensor8.getStateUint32() << 8;
val |= io_fybh_read1.getStateUint32() << 9;
val |= io_fybh_read2.getStateUint32() << 10;
val |= io_fybh_read3.getStateUint32() << 11;
val |= io_fybh_read4.getStateUint32() << 12;
val |= io_fybh_read5.getStateUint32() << 13;
val |= io_fybh_read6.getStateUint32() << 14;
return val;
}
icps::error_t Main::onHostRegisterWriteEvent(IflytopCanProtocolStackProcesser *processer, icps::WriteEvent *event) { return icps::kSuccess; }
icps::error_t Main::onHostRegisterReadEvent(IflytopCanProtocolStackProcesser *processer, icps::ReadEvent *event) { return icps::kSuccess; }
@ -111,7 +93,6 @@ void Main::run() {
* GPIO输入初始化 *
*******************************************************************************/
input_sensors_init();
intput_sensors_get_table0();
/*******************************************************************************
* *
@ -174,6 +155,27 @@ void Main::run() {
});
}
m_ioControlService.initialize(&m_protocolStack, GPIO_INPUT_ADD_BASE, nullptr, [this](int io_off) {
if (io_off == 0) return io_fybjl_sensor0.getState();
if (io_off == 1) return io_fybjl_sensor1.getState();
if (io_off == 2) return io_fybjl_sensor2.getState();
if (io_off == 3) return io_fybjl_sensor3.getState();
if (io_off == 4) return io_fybjl_sensor4.getState();
if (io_off == 5) return io_fybjl_sensor5.getState();
if (io_off == 6) return io_fybjl_sensor6.getState();
if (io_off == 7) return io_fybjl_sensor7.getState();
if (io_off == 8) return io_fybjl_sensor8.getState();
if (io_off == 9) return io_fybh_read1.getState();
if (io_off == 10) return io_fybh_read2.getState();
if (io_off == 11) return io_fybh_read3.getState();
if (io_off == 12) return io_fybh_read4.getState();
if (io_off == 13) return io_fybh_read5.getState();
if (io_off == 14) return io_fybh_read6.getState();
return false;
});
/*******************************************************************************
* *
*******************************************************************************/
@ -224,7 +226,6 @@ void Main::run() {
m_tjMotorControlService.cfg_runtohome_max_distance->setVal(INT32_MAX);
m_tjMotorControlService.cfg_runtohome_leave_zero_point_distance->setVal(256 * 200 * 1);
{
#if 0

1
usrc/project.hpp

@ -45,7 +45,6 @@
#define DEVICE_BASIC_CONTROLLER_ADD_BASE 0
#define GPIO_INPUT_ADD_BASE 1000 // GPIO输入
#define REG_GPIO_INPUT0 (GPIO_INPUT_ADD_BASE + 0)
#define REG_PY_MOTOR_CTRL_ADD_BASE 10000 // 控制 入料电机控制
#define REG_TJ_MOTOR_CTRL_ADD_BASE 10100 // 控制 转移电机控制

Loading…
Cancel
Save