7 changed files with 140 additions and 54 deletions
-
2iflytop_canbus_protocol
-
4usrc/base/config_service.cpp
-
37usrc/base/hardware.cpp
-
46usrc/base/hardware.hpp
-
11usrc/main.cpp
-
92usrc/protocol_impl/protocol_impl_service.cpp
-
2zsdk
@ -1 +1 @@ |
|||
Subproject commit 26cce0d53b0e3332d7a658f0032779a18ce97128 |
|||
Subproject commit c01f84e2ad44f02f615ceec55762e9eda995c0a1 |
@ -0,0 +1,37 @@ |
|||
#include "hardware.hpp"
|
|||
|
|||
#include "zsdk/zcanreceiver/zcanreceiver.hpp"
|
|||
#define TAG "PROTO"
|
|||
using namespace iflytop; |
|||
|
|||
/***********************************************************************************************************************
|
|||
* EXT * |
|||
***********************************************************************************************************************/ |
|||
void Hardware::init() { |
|||
m_motor_spi.init(&MOTOR_SPI); |
|||
m_modbusBlockHost.initialize(&huart3); |
|||
|
|||
m_sl_mini_ac_ctrl.initAsOutput(PD14, kxs_gpio_nopull, true, false); // m_sl_mini_ac_ctrl
|
|||
m_atta_mini_air_compressor_ctrl.initAsOutput(PD15, kxs_gpio_nopull, true, false); // m_atta_mini_air_compressor_ctrl
|
|||
|
|||
m_motor[0].initialize(&m_motor_spi, MOTOR1_ENN, MOTOR1_CSN); |
|||
m_motor[0].setIHOLD_IRUN(1, 15, 0); |
|||
m_motor[0].setMotorShaft(true); |
|||
m_motor[0].setAcceleration(300000); |
|||
m_motor[0].setDeceleration(300000); |
|||
|
|||
m_motor[1].initialize(&m_motor_spi, MOTOR2_ENN, MOTOR2_CSN); |
|||
m_motor[1].setIHOLD_IRUN(1, 15, 0); |
|||
m_motor[1].setMotorShaft(true); |
|||
m_motor[1].setAcceleration(300000); |
|||
m_motor[1].setDeceleration(300000); |
|||
|
|||
int32_t chipv0 = m_motor[0].readChipVERSION(); // 5130:0x11
|
|||
int32_t chipv1 = m_motor[1].readChipVERSION(); // 5130:0x11
|
|||
|
|||
// m_motor[0].rotate(500000);
|
|||
// m_motor[1].rotate(500000);
|
|||
ZLOGI(TAG, "chipv0: %x, chipv1: %x", chipv0, chipv1); |
|||
|
|||
m_pressureSensorBus.init(&m_modbusBlockHost, nullptr, 1000, 1000); |
|||
} |
@ -0,0 +1,46 @@ |
|||
#include <stddef.h>
|
|||
#include <stdio.h>
|
|||
|
|||
#include "base/config_service.hpp"
|
|||
#include "base/device_info.hpp"
|
|||
#include "spi.h"
|
|||
#include "usart.h"
|
|||
#include "zsdk/modbus/modbus_block_host.hpp"
|
|||
#include "zsdk/pxx_pressure_sensor_driver/pxx_pressure_sensor_bus.hpp"
|
|||
#include "zsdk/tmc/ztmc5130.hpp"
|
|||
#include "zsdk/zsdk.hpp"
|
|||
|
|||
void hardware_init(); |
|||
|
|||
namespace iflytop { |
|||
class Hardware { |
|||
ZSPI m_motor_spi; //
|
|||
ModbusBlockHost m_modbusBlockHost; //
|
|||
|
|||
TMC5130 m_motor[2]; // 蠕动泵控制
|
|||
ZGPIO m_sl_mini_ac_ctrl; // 喷液空压机(MINI)
|
|||
ZGPIO m_atta_mini_air_compressor_ctrl; // 气密性测试空压机(MINI)
|
|||
PXXPressureSensorBus m_pressureSensorBus; // PXX压力传感器总线
|
|||
|
|||
public: |
|||
static Hardware& ins() { |
|||
static Hardware ins; |
|||
return ins; |
|||
} |
|||
|
|||
void init(); |
|||
|
|||
int32_t motorNum() { return ZARRAY_SIZE(m_motor); } |
|||
TMC5130* motor(int32_t index) { |
|||
if (index < ZARRAY_SIZE(m_motor)) { |
|||
return &m_motor[index]; |
|||
} |
|||
return nullptr; |
|||
} |
|||
ZGPIO* sl_mini_ac_ctrl() { return &m_sl_mini_ac_ctrl; } |
|||
ZGPIO* atta_mini_air_compressor_ctrl() { return &m_atta_mini_air_compressor_ctrl; } |
|||
|
|||
PXXPressureSensorBus* pressureSensorBus() { return &m_pressureSensorBus; } |
|||
}; |
|||
|
|||
} // namespace iflytop
|
@ -1 +1 @@ |
|||
Subproject commit de4e73aa05048332167a744fe64118ca4bc6b0d7 |
|||
Subproject commit b8f10eae25ded517701a56b1e609f6608ed04f7a |
Write
Preview
Loading…
Cancel
Save
Reference in new issue