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.

87 lines
3.3 KiB

  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 "global.hpp"
  28. // #include "M3078CodeScanner"
  29. #define TAG "main"
  30. using namespace iflytop;
  31. using namespace std;
  32. static ZModuleDeviceManager g_zModuleDeviceManager;
  33. static MicroComputerModuleDeviceScriptCmderPaser g_zModuleDeviceScriptCmderPaser;
  34. static ZIProtocolProxy proxy[255];
  35. void cmdline_version_main() {
  36. chip_cfg_t chipcfg;
  37. chipcfg.us_dleay_tim = &PC_SYS_DELAY_US_TIMER;
  38. chipcfg.tim_irq_scheduler_tim = &PC_SYS_TIM_IRQ_SCHEDULER_TIMER;
  39. chipcfg.huart = &PC_DEBUG_UART;
  40. chipcfg.debuglight = PC_DEBUG_LIGHT_GPIO;
  41. chip_init(&chipcfg);
  42. zos_cfg_t zoscfg;
  43. zos_init(&zoscfg);
  44. ZLOGI(TAG, "boardId:%d", 0);
  45. ZLOGI(TAG, "init can bus");
  46. auto* m_zcanCommnaderMaster_cfg = g_zcanCommnaderMaster.createCFG(); // can��������
  47. g_zcanCommnaderMaster.init(m_zcanCommnaderMaster_cfg); // can����
  48. g_zModuleDeviceManager.initialize(&g_zcanCommnaderMaster);
  49. ZLOGI(TAG, "init can bus end...");
  50. static ZUARTDmaReceiver dmaUartReceiver;
  51. static CmdSchedulerV2 cmder;
  52. ZUARTDmaReceiver::hardware_config_t cfg = {
  53. .huart = &PC_DEBUG_UART,
  54. .dma_rx = &PC_DEBUG_UART_DMA_HANDLER,
  55. .rxbuffersize = PC_DEBUG_UART_RX_BUF_SIZE,
  56. .rxovertime_ms = 10,
  57. };
  58. ZLOGI(TAG, "init cmder");
  59. dmaUartReceiver.initialize(&cfg);
  60. cmder.initialize(&dmaUartReceiver);
  61. ZLOGI(TAG, "init cmder end...");
  62. ZLOGI(TAG, "init module");
  63. g_zModuleDeviceManager.initialize(&g_zcanCommnaderMaster);
  64. g_zModuleDeviceScriptCmderPaser.initialize(&cmder, &g_zModuleDeviceManager);
  65. ZLOGI(TAG, "reg modules");
  66. for (size_t i = 1; i < 255; i++) {
  67. proxy[i].initialize(i, &g_zcanCommnaderMaster);
  68. g_zModuleDeviceManager.registerModule(&proxy[i]);
  69. }
  70. ZLOGI(TAG, "board init ok...");
  71. while (true) {
  72. OSDefaultSchduler::getInstance()->loop();
  73. cmder.schedule();
  74. }
  75. };