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.

105 lines
3.9 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. #include <stddef.h>
  2. #include <stdio.h>
  3. #include "sdk/os/zos.hpp"
  4. #include "sdk\components\flash\zsimple_flash.hpp"
  5. #include "sdk\components\zcancmder\zcanreceiver.hpp"
  6. #include "sdk\components\zcancmder_module\zcan_basic_order_module.hpp"
  7. #include "sdk\components\zprotocols\zcancmder_v2\protocol_parser.hpp"
  8. //
  9. #include "sdk\components\flash\znvs.hpp"
  10. //
  11. #include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp"
  12. #include "sdk\components\cmdscheduler\cmd_scheduler_v2.hpp"
  13. #include "sdk\components\hardware\uart\zuart_dma_receiver.hpp"
  14. #include "sdk\components\mini_servo_motor\mini_servo_motor_ctrl_module.hpp"
  15. #include "sdk\components\pipette_module\pipette_ctrl_module_v2.hpp"
  16. #include "sdk\components\sensors\m3078\m3078_code_scaner.hpp"
  17. #include "sdk\components\sensors\tmp117\tmp117.hpp"
  18. #include "sdk\components\ti\drv8710.hpp"
  19. #include "sdk\components\tmc\ic\ztmc5130.hpp"
  20. #include "sdk\components\water_cooling_temperature_control_module\pwm_ctrl_module.hpp"
  21. #include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module.hpp"
  22. #include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module_factory.cpp"
  23. #include "sdk\components\water_cooling_temperature_control_module\water_cooling_temperature_control_module_factory.hpp"
  24. #include "sdk\components\zcancmder\zcan_board_module.hpp"
  25. #include "sdk\components\zcancmder\zcanreceiver_master.hpp"
  26. #include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
  27. #include "sdk\components\zprotocols\zcancmder_v2\protocol_proxy.hpp"
  28. #include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
  29. // #include "M3078CodeScanner"
  30. #define TAG "main"
  31. using namespace iflytop;
  32. using namespace std;
  33. extern void umain();
  34. extern "C" {
  35. void StartDefaultTask(void const* argument) { umain(); }
  36. }
  37. static ZModuleDeviceManager g_zModuleDeviceManager;
  38. static MicroComputerModuleDeviceScriptCmderPaser g_zModuleDeviceScriptCmderPaser;
  39. static ZCanCommnaderMaster m_zcanCommnaderMaster;
  40. static ZIProtocolProxy proxy[255];
  41. void initcfg() {
  42. /**
  43. * @brief ʼãϵͳҪöҪгʼ
  44. */
  45. static I_StepMotorCtrlModule::flash_config_t cfg;
  46. StepMotorCtrlModule::create_default_cfg(cfg);
  47. // ZNVS::ins().alloc_config(MOTOR_CFG_FLASH_MARK, (uint8_t*)&cfg, sizeof(cfg));
  48. }
  49. void initmodule() {}
  50. void umain() {
  51. chip_cfg_t chipcfg;
  52. chipcfg.us_dleay_tim = &PC_SYS_DELAY_US_TIMER;
  53. chipcfg.tim_irq_scheduler_tim = &PC_SYS_TIM_IRQ_SCHEDULER_TIMER;
  54. chipcfg.huart = &PC_DEBUG_UART;
  55. chipcfg.debuglight = PC_DEBUG_LIGHT_GPIO;
  56. chip_init(&chipcfg);
  57. zos_cfg_t zoscfg;
  58. zos_init(&zoscfg);
  59. ZLOGI(TAG, "boardId:%d", 0);
  60. ZLOGI(TAG, "init can bus");
  61. auto* m_zcanCommnaderMaster_cfg = m_zcanCommnaderMaster.createCFG(); // can��������
  62. m_zcanCommnaderMaster.init(m_zcanCommnaderMaster_cfg); // can����
  63. g_zModuleDeviceManager.initialize(&m_zcanCommnaderMaster);
  64. ZLOGI(TAG, "init can bus end...");
  65. static ZUARTDmaReceiver dmaUartReceiver;
  66. static CmdSchedulerV2 cmder;
  67. ZUARTDmaReceiver::hardware_config_t cfg = {
  68. .huart = &PC_DEBUG_UART,
  69. .dma_rx = &PC_DEBUG_UART_DMA_HANDLER,
  70. .rxbuffersize = PC_DEBUG_UART_RX_BUF_SIZE,
  71. .rxovertime_ms = 10,
  72. };
  73. ZLOGI(TAG, "init cmder");
  74. dmaUartReceiver.initialize(&cfg);
  75. cmder.initialize(&dmaUartReceiver);
  76. ZLOGI(TAG, "init cmder end...");
  77. ZLOGI(TAG, "init module");
  78. g_zModuleDeviceManager.initialize(nullptr);
  79. g_zModuleDeviceScriptCmderPaser.initialize(&cmder, &g_zModuleDeviceManager);
  80. for (size_t i = 1; i < 255; i++) {
  81. proxy[i].initialize(i, &m_zcanCommnaderMaster);
  82. g_zModuleDeviceManager.registerModule(&proxy[i]);
  83. }
  84. ZLOGI(TAG, "board init ok...");
  85. while (true) {
  86. OSDefaultSchduler::getInstance()->loop();
  87. cmder.schedule();
  88. }
  89. };