diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index ece75d4..7108896 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/sdk b/sdk index 14aa923..7a54e6e 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit 14aa923a01977e661bf9fab86cbb30aeb575f162 +Subproject commit 7a54e6e7ad92b17f22a1287a2d8f0cb269bceaf6 diff --git a/usrc/board.h b/usrc/board.h index e69de29..6f70f09 100644 --- a/usrc/board.h +++ b/usrc/board.h @@ -0,0 +1 @@ +#pragma once diff --git a/usrc/cmdline_version.cpp b/usrc/cmdline_version.cpp new file mode 100644 index 0000000..1c0f791 --- /dev/null +++ b/usrc/cmdline_version.cpp @@ -0,0 +1,87 @@ +#include +#include + +#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 "global.hpp" +// #include "M3078CodeScanner" + +#define TAG "main" +using namespace iflytop; +using namespace std; +static ZModuleDeviceManager g_zModuleDeviceManager; +static MicroComputerModuleDeviceScriptCmderPaser g_zModuleDeviceScriptCmderPaser; +static ZIProtocolProxy proxy[255]; + +void cmdline_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 = &PC_DEBUG_UART; + 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总线 + g_zModuleDeviceManager.initialize(&g_zcanCommnaderMaster); + 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 = 10, + }; + ZLOGI(TAG, "init cmder"); + dmaUartReceiver.initialize(&cfg); + cmder.initialize(&dmaUartReceiver); + ZLOGI(TAG, "init cmder end..."); + + ZLOGI(TAG, "init module"); + g_zModuleDeviceManager.initialize(&g_zcanCommnaderMaster); + g_zModuleDeviceScriptCmderPaser.initialize(&cmder, &g_zModuleDeviceManager); + ZLOGI(TAG, "reg modules"); + + for (size_t i = 1; i < 255; i++) { + proxy[i].initialize(i, &g_zcanCommnaderMaster); + g_zModuleDeviceManager.registerModule(&proxy[i]); + } + + ZLOGI(TAG, "board init ok..."); + + while (true) { + OSDefaultSchduler::getInstance()->loop(); + cmder.schedule(); + } +}; diff --git a/usrc/cmdline_version.hpp b/usrc/cmdline_version.hpp new file mode 100644 index 0000000..320a69b --- /dev/null +++ b/usrc/cmdline_version.hpp @@ -0,0 +1,3 @@ +#pragma once +void cmdline_version_main(); + diff --git a/usrc/global.cpp b/usrc/global.cpp new file mode 100644 index 0000000..009b73b --- /dev/null +++ b/usrc/global.cpp @@ -0,0 +1,9 @@ + +#include "sdk\components\zcancmder\zcanreceiver_master.hpp" +namespace iflytop { +ZGPIO g_Key0; +ZGPIO g_Key1; +ZGPIO g_Key2; +ZGPIO g_StateLight1; +ZCanCommnaderMaster g_zcanCommnaderMaster; +} // namespace iflytop \ No newline at end of file diff --git a/usrc/global.hpp b/usrc/global.hpp new file mode 100644 index 0000000..9612761 --- /dev/null +++ b/usrc/global.hpp @@ -0,0 +1,10 @@ +#pragma once +#include "sdk\components\zcancmder\zcanreceiver_master.hpp" + +namespace iflytop { +extern ZGPIO g_Key0; +extern ZGPIO g_Key1; +extern ZGPIO g_Key2; +extern ZGPIO g_StateLight1; +extern ZCanCommnaderMaster g_zcanCommnaderMaster; +} // namespace iflytop \ No newline at end of file diff --git a/usrc/main.cpp b/usrc/main.cpp index 5e053e2..e7f910f 100644 --- a/usrc/main.cpp +++ b/usrc/main.cpp @@ -1,98 +1,31 @@ #include #include +#include "cmdline_version.hpp" +#include "global.hpp" +#include "project_configs.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 "M3078CodeScanner" +#include "transparent_version.hpp" #define TAG "main" -using namespace iflytop; using namespace std; +using namespace iflytop; extern void umain(); extern "C" { void StartDefaultTask(void const* argument) { umain(); } } -static ZModuleDeviceManager g_zModuleDeviceManager; -static MicroComputerModuleDeviceScriptCmderPaser g_zModuleDeviceScriptCmderPaser; -static ZCanCommnaderMaster m_zcanCommnaderMaster; -static ZIProtocolProxy proxy[255]; - -void initcfg() { - -} - -void initmodule() {} - void umain() { - 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", 0); - - ZLOGI(TAG, "init can bus"); - auto* m_zcanCommnaderMaster_cfg = m_zcanCommnaderMaster.createCFG(); // can总线配置 - m_zcanCommnaderMaster.init(m_zcanCommnaderMaster_cfg); // can总线 - g_zModuleDeviceManager.initialize(&m_zcanCommnaderMaster); - 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 = 10, - }; - ZLOGI(TAG, "init cmder"); - dmaUartReceiver.initialize(&cfg); - cmder.initialize(&dmaUartReceiver); - ZLOGI(TAG, "init cmder end..."); - - ZLOGI(TAG, "init module"); - g_zModuleDeviceManager.initialize(nullptr); - g_zModuleDeviceScriptCmderPaser.initialize(&cmder, &g_zModuleDeviceManager); - - for (size_t i = 1; i < 255; i++) { - proxy[i].initialize(i, &m_zcanCommnaderMaster); - g_zModuleDeviceManager.registerModule(&proxy[i]); - } - - ZLOGI(TAG, "board init ok..."); - - while (true) { - OSDefaultSchduler::getInstance()->loop(); - cmder.schedule(); + g_Key0.initAsInput(KEY0, ZGPIO::kMode_pullup, ZGPIO::kIRQ_noIrq, false); + g_StateLight1.initAsOutput(STATE_LIGHT_GPIO, ZGPIO::kMode_pullup, false, false); + + if (g_Key0.getState()) { + g_StateLight1.setState(true); + cmdline_version_main(); + } else { + g_StateLight1.setState(false); + transparent_version_main(); } }; diff --git a/usrc/project_configs.h b/usrc/project_configs.h index 4928b70..d32664c 100644 --- a/usrc/project_configs.h +++ b/usrc/project_configs.h @@ -1,9 +1,9 @@ #pragma once -#define PC_VERSION "v1.0.0" -#define PC_MANUFACTURER "http://www.iflytop.com/" -#define PC_PROJECT_NAME "zcancmder_debug_board" -#define PC_IFLYTOP_ENABLE_OS 1 +#define PC_VERSION "v1.0.0" +#define PC_MANUFACTURER "http://www.iflytop.com/" +#define PC_PROJECT_NAME "zcancmder_debug_board" +#define PC_IFLYTOP_ENABLE_OS 1 #define PC_DEBUG_UART huart1 #define PC_DEBUG_UART_DMA_HANDLER hdma_usart1_rx @@ -18,3 +18,11 @@ #define PC_NVS_ENABLE 1 #define PC_NVS_CONFIG_FLASH_SECTOR 8 + +// ---------------------------------------------------------------------- + +#define STATE_LIGHT_GPIO PF10 + +#define KEY0 PE4 +#define KEY1 PE3 +#define KEY2 PE2 diff --git a/usrc/transparent_version.cpp b/usrc/transparent_version.cpp new file mode 100644 index 0000000..241848d --- /dev/null +++ b/usrc/transparent_version.cpp @@ -0,0 +1,89 @@ +#include +#include + +#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; + } + } +}; diff --git a/usrc/transparent_version.hpp b/usrc/transparent_version.hpp new file mode 100644 index 0000000..531df61 --- /dev/null +++ b/usrc/transparent_version.hpp @@ -0,0 +1,3 @@ +#pragma once +void transparent_version_main(); + diff --git a/zcancmder_debug_board.ioc b/zcancmder_debug_board.ioc index ae71a8d..f958b88 100644 --- a/zcancmder_debug_board.ioc +++ b/zcancmder_debug_board.ioc @@ -95,7 +95,7 @@ Dma.USART3_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphData FREERTOS.FootprintOK=true FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_RECURSIVE_MUTEXES,configUSE_NEWLIB_REENTRANT,configTOTAL_HEAP_SIZE FREERTOS.Tasks01=defaultTask,0,512,StartDefaultTask,As weak,NULL,Dynamic,NULL,NULL -FREERTOS.configTOTAL_HEAP_SIZE=30000 +FREERTOS.configTOTAL_HEAP_SIZE=20000 FREERTOS.configUSE_NEWLIB_REENTRANT=1 FREERTOS.configUSE_RECURSIVE_MUTEXES=1 File.Version=6