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.

103 lines
3.7 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\zcancmder\zcan_board_module.hpp"
  23. #include "sdk\components\zcancmder\zcanreceiver_master.hpp"
  24. #include "sdk\components\zprotocol_helper\micro_computer_module_device_script_cmder_paser.hpp"
  25. #include "sdk\components\zprotocols\zcancmder_v2\protocol_proxy.hpp"
  26. #include "sdk\components\zprotocols\zcancmder_v2\zmodule_device_manager.hpp"
  27. // #include "M3078CodeScanner"
  28. #define TAG "main"
  29. using namespace iflytop;
  30. using namespace std;
  31. extern void umain();
  32. extern "C" {
  33. void StartDefaultTask(void const* argument) { umain(); }
  34. }
  35. static ZModuleDeviceManager g_zModuleDeviceManager;
  36. static MicroComputerModuleDeviceScriptCmderPaser g_zModuleDeviceScriptCmderPaser;
  37. static ZCanCommnaderMaster m_zcanCommnaderMaster;
  38. static ZIProtocolProxy proxy[255];
  39. void initcfg() {
  40. /**
  41. * @brief ʼãϵͳҪöҪгʼ
  42. */
  43. static I_StepMotorCtrlModule::flash_config_t cfg;
  44. StepMotorCtrlModule::create_default_cfg(cfg);
  45. // ZNVS::ins().alloc_config(MOTOR_CFG_FLASH_MARK, (uint8_t*)&cfg, sizeof(cfg));
  46. }
  47. void initmodule() {}
  48. void umain() {
  49. chip_cfg_t chipcfg;
  50. chipcfg.us_dleay_tim = &PC_SYS_DELAY_US_TIMER;
  51. chipcfg.tim_irq_scheduler_tim = &PC_SYS_TIM_IRQ_SCHEDULER_TIMER;
  52. chipcfg.huart = &PC_DEBUG_UART;
  53. chipcfg.debuglight = PC_DEBUG_LIGHT_GPIO;
  54. chip_init(&chipcfg);
  55. zos_cfg_t zoscfg;
  56. zos_init(&zoscfg);
  57. ZLOGI(TAG, "boardId:%d", 0);
  58. ZLOGI(TAG, "init can bus");
  59. auto* m_zcanCommnaderMaster_cfg = m_zcanCommnaderMaster.createCFG(); // can��������
  60. m_zcanCommnaderMaster.init(m_zcanCommnaderMaster_cfg); // can����
  61. g_zModuleDeviceManager.initialize(&m_zcanCommnaderMaster);
  62. ZLOGI(TAG, "init can bus end...");
  63. static ZUARTDmaReceiver dmaUartReceiver;
  64. static CmdSchedulerV2 cmder;
  65. ZUARTDmaReceiver::hardware_config_t cfg = {
  66. .huart = &PC_DEBUG_UART,
  67. .dma_rx = &PC_DEBUG_UART_DMA_HANDLER,
  68. .rxbuffersize = PC_DEBUG_UART_RX_BUF_SIZE,
  69. .rxovertime_ms = 10,
  70. };
  71. ZLOGI(TAG, "init cmder");
  72. dmaUartReceiver.initialize(&cfg);
  73. cmder.initialize(&dmaUartReceiver);
  74. ZLOGI(TAG, "init cmder end...");
  75. ZLOGI(TAG, "init module");
  76. g_zModuleDeviceManager.initialize(nullptr);
  77. g_zModuleDeviceScriptCmderPaser.initialize(&cmder, &g_zModuleDeviceManager);
  78. for (size_t i = 1; i < 255; i++) {
  79. proxy[i].initialize(i, &m_zcanCommnaderMaster);
  80. g_zModuleDeviceManager.registerModule(&proxy[i]);
  81. }
  82. ZLOGI(TAG, "board init ok...");
  83. while (true) {
  84. OSDefaultSchduler::getInstance()->loop();
  85. cmder.schedule();
  86. }
  87. };