|
|
@ -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
|
|
|
|
|
|
|
|