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.
 
 
 

89 lines
3.2 KiB

#include <stddef.h>
#include <stdio.h>
#include "sdk/os/zos.hpp"
#include "sdk\components\flash\zsimple_flash.hpp"
#include "sdk\components\zcancmder\zcanreceiver.hpp"
#include "sdk\components\zcancmder_module\zcan_basic_order_module.hpp"
#include "sdk\components\zprotocols\zcancmder_v2\protocol_parser.hpp"
//
#include "sdk\components\flash\znvs.hpp"
//
#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
#include "sdk\components\cmdscheduler\cmd_scheduler_v2.hpp"
#include "sdk\components\hardware\uart\zuart_dma_receiver.hpp"
#include "sdk\components\mini_servo_motor\mini_servo_motor_ctrl_module.hpp"
#include "sdk\components\pipette_module\pipette_ctrl_module_v2.hpp"
#include "sdk\components\sensors\m3078\m3078_code_scaner.hpp"
#include "sdk\components\sensors\tmp117\tmp117.hpp"
#include "sdk\components\ti\drv8710.hpp"
#include "sdk\components\tmc\ic\ztmc5130.hpp"
#include "sdk\components\water_cooling_temperature_control_module\pwm_ctrl_module.hpp"
#include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module.hpp"
#include "sdk\components\zcancmder\zcan_board_module.hpp"
#include "sdk\components\zcancmder\zcanreceiver_master.hpp"
#include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
#include "sdk\components\zprotocols\zcancmder_v2\protocol_proxy.hpp"
#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
#include "string.h"
// #include "M3078CodeScanner"
#include "global.hpp"
#define TAG "main"
using namespace iflytop;
using namespace std;
uint32_t m_rxbufsize;
bool m_dataisready = false;
char m_cmdcache[1024] = {0};
void transparent_version_main() {
chip_cfg_t chipcfg;
chipcfg.us_dleay_tim = &PC_SYS_DELAY_US_TIMER;
chipcfg.tim_irq_scheduler_tim = &PC_SYS_TIM_IRQ_SCHEDULER_TIMER;
chipcfg.huart = NULL;
chipcfg.debuglight = PC_DEBUG_LIGHT_GPIO;
chip_init(&chipcfg);
zos_cfg_t zoscfg;
zos_init(&zoscfg);
ZLOGI(TAG, "boardId:%d", 0);
ZLOGI(TAG, "init can bus");
auto* m_zcanCommnaderMaster_cfg = g_zcanCommnaderMaster.createCFG(); // can×ÜÏßÅäÖÃ
g_zcanCommnaderMaster.init(m_zcanCommnaderMaster_cfg); // can×ÜÏß
ZLOGI(TAG, "init can bus end...");
static ZUARTDmaReceiver dmaUartReceiver;
static CmdSchedulerV2 cmder;
ZUARTDmaReceiver::hardware_config_t cfg = {
.huart = &PC_DEBUG_UART,
.dma_rx = &PC_DEBUG_UART_DMA_HANDLER,
.rxbuffersize = PC_DEBUG_UART_RX_BUF_SIZE,
.rxovertime_ms = 3,
};
ZLOGI(TAG, "init cmder");
dmaUartReceiver.initialize(&cfg);
dmaUartReceiver.startRx([](uint8_t* data, size_t len) {
if (!m_dataisready) {
memcpy(m_cmdcache, data, len);
m_rxbufsize = len;
m_dataisready = true;
}
});
g_zcanCommnaderMaster.regRawPacketListener([](uint8_t* packet, size_t len) { //
HAL_UART_Transmit(&PC_DEBUG_UART, packet, len, 1000);
osDelay(5);
});
while (true) {
OSDefaultSchduler::getInstance()->loop();
if (m_dataisready) {
g_zcanCommnaderMaster.sendRawPacket((uint8_t*)m_cmdcache, m_rxbufsize);
m_dataisready = false;
}
}
};