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.
116 lines
4.3 KiB
116 lines
4.3 KiB
#include "main.hpp"
|
|
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
|
|
#include "main.h"
|
|
#include "project.hpp"
|
|
//
|
|
#include "one_dimensional_code_laser_scanner.hpp"
|
|
// #include "sdk/components/single_axis_motor_control_v2/single_axis_motor_control_v2.hpp"
|
|
#include "sdk/components/iflytop_can_slave_modules/idcard_reader_service.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\m3078\m3078_code_scaner.hpp"
|
|
#include "sdk\components\tmc\ic\ztmc4361A.hpp"
|
|
#include "sdk\components\tmc\ic\ztmc5130.hpp"
|
|
|
|
#define TAG "main"
|
|
namespace iflytop {
|
|
Main gmain;
|
|
};
|
|
|
|
using namespace iflytop;
|
|
|
|
IflytopCanProtocolStackProcesser m_protocolStack;
|
|
|
|
TMC5130 m_tj_motor;
|
|
TMC5130 m_py_motor;
|
|
|
|
ZGPIO debuglight;
|
|
|
|
ZGPIO io_fybh_read1;
|
|
ZGPIO io_fybh_read2;
|
|
ZGPIO io_fybh_read3;
|
|
ZGPIO io_fybh_read4;
|
|
ZGPIO io_fybh_read5;
|
|
ZGPIO io_fybh_read6;
|
|
|
|
ZGPIO io_fybjl_sensor8;
|
|
ZGPIO io_fybjl_sensor7;
|
|
ZGPIO io_fybjl_sensor6;
|
|
ZGPIO io_fybjl_sensor5;
|
|
ZGPIO io_fybjl_sensor4;
|
|
ZGPIO io_fybjl_sensor3;
|
|
ZGPIO io_fybjl_sensor2;
|
|
ZGPIO io_fybjl_sensor1;
|
|
ZGPIO io_fybjl_sensor0;
|
|
|
|
M3078CodeScanner m_m3078CodeScanner;
|
|
|
|
DeviceBaseControlService m_deviceBaseControlService;
|
|
IOControlService m_ioControlService;
|
|
SingleAxisMotorControler m_pyMotorControlService; // 平移电机
|
|
SingleAxisMotorControler m_tjMotorControlService; // 推进电机
|
|
OneDimensionalCodeLaserScanner m_oneDimensionalCodeLaserScanner;
|
|
IDCardReaderService m_idCardReaderService;
|
|
|
|
ZCanReceiver m_canReceiver;
|
|
|
|
void input_sensors_init() {
|
|
io_fybh_read1.initAsInput(FYBH_READ1, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false /*mirror*/);
|
|
io_fybh_read2.initAsInput(FYBH_READ2, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false /*mirror*/);
|
|
io_fybh_read3.initAsInput(FYBH_READ3, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false /*mirror*/);
|
|
io_fybh_read4.initAsInput(FYBH_READ4, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false /*mirror*/);
|
|
io_fybh_read5.initAsInput(FYBH_READ5, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false /*mirror*/);
|
|
io_fybh_read6.initAsInput(FYBH_READ6, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false /*mirror*/);
|
|
|
|
io_fybjl_sensor8.initAsInput(FYBJL_SENSOR8, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true /*mirror*/);
|
|
io_fybjl_sensor7.initAsInput(FYBJL_SENSOR7, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true /*mirror*/);
|
|
io_fybjl_sensor6.initAsInput(FYBJL_SENSOR6, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true /*mirror*/);
|
|
io_fybjl_sensor5.initAsInput(FYBJL_SENSOR5, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true /*mirror*/);
|
|
io_fybjl_sensor4.initAsInput(FYBJL_SENSOR4, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true /*mirror*/);
|
|
io_fybjl_sensor3.initAsInput(FYBJL_SENSOR3, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true /*mirror*/);
|
|
io_fybjl_sensor2.initAsInput(FYBJL_SENSOR2, ZGPIO::kMode_nopull, ZGPIO::kIRQ_risingAndFallingIrq, true /*mirror*/);
|
|
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*/);
|
|
}
|
|
|
|
void Main::onRceivePacket(CanPacketRxBuffer *rxbuf, uint8_t *packet, size_t len) {
|
|
ZLOGI(TAG, "onRceivePacket from %d %d", rxbuf->id, len);
|
|
for (size_t i = 0; i < len; i++) {
|
|
printf("%02X ", packet[i]);
|
|
}
|
|
printf("\n");
|
|
}
|
|
|
|
void Main::run() {
|
|
ZHALCORE::cfg_t oscfg = {
|
|
.delayhtim = &DELAY_US_TIMER,
|
|
.debuguart = &DEBUG_UART,
|
|
};
|
|
ZHALCORE::getInstance()->initialize(oscfg);
|
|
|
|
ZLOGI(TAG, "zapp:%s", VERSION);
|
|
printf("int32_t %d int %d longint %d\n", sizeof(int32_t), sizeof(int), sizeof(long int));
|
|
|
|
debuglight.initAsOutput(DEBUG_LIGHT_GPIO, ZGPIO::kMode_nopull, false, false);
|
|
ZHAL_CORE_REG(200, { debuglight.toggleState(); });
|
|
|
|
ZCanReceiver::CFG *cfg = m_canReceiver.createCFG(DEVICE_ID);
|
|
m_canReceiver.init(cfg);
|
|
m_canReceiver.registerListener(this);
|
|
|
|
// uint8_t packet[255];
|
|
// for (int i = 0; i < 255; i++) {
|
|
// packet[i] = i;
|
|
// }
|
|
// ZHAL_CORE_REG(200, { m_canReceiver.sendPacket(packet, 255); });
|
|
|
|
ZLOGI(TAG, "init done");
|
|
while (1) {
|
|
ZHALCORE::getInstance()->loop();
|
|
}
|
|
}
|