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.
|
|
#include "main.hpp"
#include <stddef.h>
#include <stdio.h>
#include "main.h"
#include "project.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"
//
#include "sdk\components\huacheng_sensor\dp600_pressure_sensor.hpp"
#include "sdk\components\zcan_module\huacheng_pressure_sensor.hpp"
#include "sdk\components\zcan_module\zcan_basic_order_module.hpp"
#include "sdk\components\zcan_module\zcan_pump_ctrl_module.hpp"
#include "sdk\components\zcan_module\zcan_trigle_warning_light_ctl_module.hpp"
//
#include "sdk\components\zcan_module\zcan_high_power_electrical_ctl_module.hpp"
#define TAG "main"
namespace iflytop { Main gmain; };
using namespace iflytop;
IflytopCanProtocolStackProcesser m_protocolStack;
// TMC5130 m_motor1;
// TMC5130 m_motor2;
ZGPIO debuglight;
ZGPIO AirCompressorCtrl1; ZGPIO AirCompressorCtrl2;
ZGPIO AirBlowerCtrl1; ZGPIO AirBlowerCtrl2;
ZGPIO HeatingStripCtrl1; ZGPIO HeatingStripCtrl2;
ZCanReceiver m_canReceiver; ZCanBasicOrderModule m_basicOrderModule; ZCanHighPowerElectricalCtlModule m_highPowerElectricalCtlModule;
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); 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);
/**
* @brief 基础模块 */ m_basicOrderModule.initialize(&m_canReceiver); m_basicOrderModule.regInputCtl([this](uint8_t id, bool &val) { return false; }); m_basicOrderModule.regOutCtl([this](uint8_t id, bool val) { if (id == 0) { AirCompressorCtrl1.setState(val); return true; } if (id == 1) { AirCompressorCtrl2.setState(val); return true; }
if (id == 2) { AirBlowerCtrl1.setState(val); return true; }
if (id == 3) { AirBlowerCtrl2.setState(val); return true; }
if (id == 4) { HeatingStripCtrl1.setState(val); return true; }
if (id == 5) { HeatingStripCtrl2.setState(val); return true; }
return false; });
m_basicOrderModule.regReadAdcVal([this](uint8_t id, int32_t &val) { if (id == 0) { val = 0; return true; } if (id == 1) { val = 0; return true; } if (id == 2) { val = 0; return true; }
return false; });
ZLOGI(TAG, "init done"); while (1) { ZHALCORE::getInstance()->loop(); } }
|