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.

89 lines
3.2 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 "string.h"
  28. // #include "M3078CodeScanner"
  29. #include "global.hpp"
  30. #define TAG "main"
  31. using namespace iflytop;
  32. using namespace std;
  33. uint32_t m_rxbufsize;
  34. bool m_dataisready = false;
  35. char m_cmdcache[1024] = {0};
  36. void transparent_version_main() {
  37. chip_cfg_t chipcfg;
  38. chipcfg.us_dleay_tim = &PC_SYS_DELAY_US_TIMER;
  39. chipcfg.tim_irq_scheduler_tim = &PC_SYS_TIM_IRQ_SCHEDULER_TIMER;
  40. chipcfg.huart = NULL;
  41. chipcfg.debuglight = PC_DEBUG_LIGHT_GPIO;
  42. chip_init(&chipcfg);
  43. zos_cfg_t zoscfg;
  44. zos_init(&zoscfg);
  45. ZLOGI(TAG, "boardId:%d", 0);
  46. ZLOGI(TAG, "init can bus");
  47. auto* m_zcanCommnaderMaster_cfg = g_zcanCommnaderMaster.createCFG(); // can��������
  48. g_zcanCommnaderMaster.init(m_zcanCommnaderMaster_cfg); // can����
  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 = 3,
  57. };
  58. ZLOGI(TAG, "init cmder");
  59. dmaUartReceiver.initialize(&cfg);
  60. dmaUartReceiver.startRx([](uint8_t* data, size_t len) {
  61. if (!m_dataisready) {
  62. memcpy(m_cmdcache, data, len);
  63. m_rxbufsize = len;
  64. m_dataisready = true;
  65. }
  66. });
  67. g_zcanCommnaderMaster.regRawPacketListener([](uint8_t* packet, size_t len) { //
  68. HAL_UART_Transmit(&PC_DEBUG_UART, packet, len, 1000);
  69. osDelay(5);
  70. });
  71. while (true) {
  72. OSDefaultSchduler::getInstance()->loop();
  73. if (m_dataisready) {
  74. g_zcanCommnaderMaster.sendRawPacket((uint8_t*)m_cmdcache, m_rxbufsize);
  75. m_dataisready = false;
  76. }
  77. }
  78. };