12 changed files with 152 additions and 16 deletions
-
6chip/chip.cpp
-
2chip/chip_tim_irq_shceduler.cpp
-
2chip/zgpio.cpp
-
2components/step_motor_45/step_motor_45_scheduler.cpp
-
7components/subcanmodule/dep.hpp
-
90components/subcanmodule/zcancmder_subboard_initer.cpp
-
39components/subcanmodule/zcancmder_subboard_initer.hpp
-
4os/delay.cpp
-
10os/mutex.cpp
-
2os/mutex.hpp
-
2os/osbasic_h.hpp
-
2os/ticket.cpp
@ -0,0 +1,7 @@ |
|||||
|
#pragma once
|
||||
|
#include "sdk\components\cmdscheduler\cmd_scheduler_v2.hpp"
|
||||
|
#include "sdk\components\hardware\uart\zuart_dma_receiver.hpp"
|
||||
|
#include "sdk\components\zcancmder\zcan_board_module.hpp"
|
||||
|
#include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
|
||||
|
#include "sdk\components\zprotocols\zcancmder_v2\protocol_parser.hpp"
|
||||
|
#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
|
@ -0,0 +1,90 @@ |
|||||
|
#include "zcancmder_subboard_initer.hpp"
|
||||
|
//
|
||||
|
#include "sdk\components\flash\znvs.hpp"
|
||||
|
//
|
||||
|
#include <stdio.h>
|
||||
|
#include <string.h>
|
||||
|
|
||||
|
#include "project_configs.h"
|
||||
|
using namespace iflytop; |
||||
|
const char* TAG = PC_PROJECT_NAME; |
||||
|
|
||||
|
__weak void nvs_init_cb() {} |
||||
|
extern DMA_HandleTypeDef PC_DEBUG_UART_DMA_HANDLER; |
||||
|
|
||||
|
int32_t ZCancmderSubboardIniter::get_module_id(int32_t moduleIndex) { return m_cfg.deviceId * 100 + moduleIndex; } |
||||
|
|
||||
|
void ZCancmderSubboardIniter::init(cfg_t* cfg) { |
||||
|
m_cfg = *cfg; |
||||
|
|
||||
|
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 = &PC_DEBUG_UART; |
||||
|
chipcfg.debuglight = PC_DEBUG_LIGHT_GPIO; |
||||
|
|
||||
|
chip_init(&chipcfg); |
||||
|
|
||||
|
zos_cfg_t zoscfg; |
||||
|
zos_init(&zoscfg); |
||||
|
|
||||
|
ZLOGI(TAG, "boardId:%d", m_cfg.deviceId); |
||||
|
|
||||
|
/*******************************************************************************
|
||||
|
* NVSINIT * |
||||
|
*******************************************************************************/ |
||||
|
|
||||
|
if (PC_NVS_ENABLE) { |
||||
|
ZNVS::ins().initialize(PC_NVS_CONFIG_FLASH_SECTOR); |
||||
|
nvs_init_cb(); |
||||
|
ZNVS::ins().init_config(); |
||||
|
} |
||||
|
|
||||
|
auto zcanCmder_cfg = zcanCmder.createCFG(m_cfg.deviceId); |
||||
|
zcanCmder.init(zcanCmder_cfg); |
||||
|
ziProtocolParser.initialize(&zcanCmder); |
||||
|
|
||||
|
{ |
||||
|
static ZUARTDmaReceiver dmaUartReceiver; |
||||
|
static 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 = 10, |
||||
|
}; |
||||
|
dmaUartReceiver.initialize(&cfg); |
||||
|
cmder.initialize(&dmaUartReceiver); |
||||
|
zModuleDeviceManager.initialize(nullptr); |
||||
|
zModuleDeviceScriptCmderPaser.initialize(&cmder, &zModuleDeviceManager); |
||||
|
} |
||||
|
|
||||
|
initmodule(); |
||||
|
} |
||||
|
|
||||
|
void ZCancmderSubboardIniter::initmodule() { |
||||
|
static ZCanBoardModule boardmodule; |
||||
|
|
||||
|
ZCanBoardModule::hardware_config_t hcfg = {}; |
||||
|
static_assert(ZARRAY_SIZE(hcfg.input) == ZARRAY_SIZE(m_cfg.input_gpio)); |
||||
|
static_assert(ZARRAY_SIZE(hcfg.output) == ZARRAY_SIZE(m_cfg.output_gpio)); |
||||
|
|
||||
|
memcpy(&hcfg.input, &m_cfg.input_gpio, sizeof(m_cfg.input_gpio)); |
||||
|
memcpy(&hcfg.output, &m_cfg.output_gpio, sizeof(m_cfg.output_gpio)); |
||||
|
|
||||
|
boardmodule.initialize(get_module_id(0), &hcfg); |
||||
|
ziProtocolParser.registerModule(&boardmodule); |
||||
|
zModuleDeviceManager.registerModule(&boardmodule); |
||||
|
} |
||||
|
|
||||
|
void ZCancmderSubboardIniter::register_module(ZIModule* module) { |
||||
|
ziProtocolParser.registerModule(module); |
||||
|
zModuleDeviceManager.registerModule(module); |
||||
|
} |
||||
|
|
||||
|
void ZCancmderSubboardIniter::loop() { |
||||
|
while (true) { |
||||
|
OSDefaultSchduler::getInstance()->loop(); |
||||
|
zcanCmder.loop(); |
||||
|
cmder.schedule(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
#pragma once
|
||||
|
#include "sdk\components\cmdscheduler\cmd_scheduler_v2.hpp"
|
||||
|
#include "sdk\components\hardware\uart\zuart_dma_receiver.hpp"
|
||||
|
#include "sdk\components\zcancmder\zcan_board_module.hpp"
|
||||
|
#include "sdk\components\zcancmder\zcanreceiver.hpp"
|
||||
|
#include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
|
||||
|
#include "sdk\components\zprotocols\zcancmder_v2\protocol_parser.hpp"
|
||||
|
#include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
|
||||
|
|
||||
|
namespace iflytop { |
||||
|
class ZCancmderSubboardIniter { |
||||
|
public: |
||||
|
typedef struct { |
||||
|
int32_t deviceId; |
||||
|
ZGPIO::InputGpioCfg_t input_gpio[10]; |
||||
|
ZGPIO::OutputGpioCfg_t output_gpio[10]; |
||||
|
} cfg_t; |
||||
|
|
||||
|
private: |
||||
|
ZCanCmder zcanCmder; |
||||
|
ZIProtocolParser ziProtocolParser; |
||||
|
ZModuleDeviceManager zModuleDeviceManager; |
||||
|
MicroComputerModuleDeviceScriptCmderPaser zModuleDeviceScriptCmderPaser; |
||||
|
CmdSchedulerV2 cmder; |
||||
|
|
||||
|
cfg_t m_cfg; |
||||
|
|
||||
|
public: |
||||
|
void init(cfg_t* cfg); |
||||
|
void register_module(ZIModule* module); |
||||
|
int32_t get_module_id(int32_t moduleIndex); |
||||
|
//
|
||||
|
void loop(); |
||||
|
|
||||
|
private: |
||||
|
int32_t getDeviceId(); |
||||
|
void initmodule(); |
||||
|
}; |
||||
|
} // namespace iflytop
|
@ -1,6 +1,6 @@ |
|||||
#pragma once
|
#pragma once
|
||||
#include "../chip/chip.hpp"
|
#include "../chip/chip.hpp"
|
||||
//
|
//
|
||||
#ifdef IFLYTOP_ENABLE_OS
|
|
||||
|
#ifdef PC_IFLYTOP_ENABLE_OS
|
||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||
#endif
|
#endif
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue