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.

136 lines
3.3 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
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 "main.hpp"
  2. #include <stddef.h>
  3. #include <stdio.h>
  4. #include "main.h"
  5. #include "project.hpp"
  6. //
  7. // #include "sdk/components/single_axis_motor_control_v2/single_axis_motor_control_v2.hpp"
  8. #include "sdk/components/iflytop_can_slave_modules/idcard_reader_service.hpp"
  9. #include "sdk/components/single_axis_motor_control/single_axis_motor_control.hpp"
  10. #include "sdk/hal/zhal.hpp"
  11. #include "sdk\components\iflytop_can_slave_modules\io_control_service.hpp"
  12. #include "sdk\components\iflytop_can_slave_v1\iflytop_can_slave.hpp"
  13. #include "sdk\components\m3078\m3078_code_scaner.hpp"
  14. #include "sdk\components\tmc\ic\ztmc4361A.hpp"
  15. #include "sdk\components\tmc\ic\ztmc5130.hpp"
  16. //
  17. #include "sdk\components\huacheng_sensor\dp600_pressure_sensor.hpp"
  18. #include "sdk\components\zcan_module\huacheng_pressure_sensor.hpp"
  19. #include "sdk\components\zcan_module\zcan_basic_order_module.hpp"
  20. #include "sdk\components\zcan_module\zcan_pump_ctrl_module.hpp"
  21. #include "sdk\components\zcan_module\zcan_trigle_warning_light_ctl_module.hpp"
  22. //
  23. #include "sdk\components\zcan_module\zcan_high_power_electrical_ctl_module.hpp"
  24. #define TAG "main"
  25. namespace iflytop {
  26. Main gmain;
  27. };
  28. using namespace iflytop;
  29. IflytopCanProtocolStackProcesser m_protocolStack;
  30. // TMC5130 m_motor1;
  31. // TMC5130 m_motor2;
  32. ZGPIO debuglight;
  33. ZGPIO AirCompressorCtrl1;
  34. ZGPIO AirCompressorCtrl2;
  35. ZGPIO AirBlowerCtrl1;
  36. ZGPIO AirBlowerCtrl2;
  37. ZGPIO HeatingStripCtrl1;
  38. ZGPIO HeatingStripCtrl2;
  39. ZCanReceiver m_canReceiver;
  40. ZCanBasicOrderModule m_basicOrderModule;
  41. ZCanHighPowerElectricalCtlModule m_highPowerElectricalCtlModule;
  42. void Main::onRceivePacket(CanPacketRxBuffer *rxbuf, uint8_t *packet, size_t len) {
  43. ZLOGI(TAG, "onRceivePacket from %d %d", rxbuf->id, len);
  44. for (size_t i = 0; i < len; i++) {
  45. printf("%02X ", packet[i]);
  46. }
  47. printf("\n");
  48. }
  49. void Main::run() {
  50. ZHALCORE::cfg_t oscfg = {
  51. .delayhtim = &DELAY_US_TIMER,
  52. .debuguart = &DEBUG_UART,
  53. };
  54. ZHALCORE::getInstance()->initialize(oscfg);
  55. ZLOGI(TAG, "zapp:%s", VERSION);
  56. debuglight.initAsOutput(DEBUG_LIGHT_GPIO, ZGPIO::kMode_nopull, false, false);
  57. ZHAL_CORE_REG(200, { debuglight.toggleState(); });
  58. ZCanReceiver::CFG *cfg = m_canReceiver.createCFG(DEVICE_ID);
  59. m_canReceiver.init(cfg);
  60. m_canReceiver.registerListener(this);
  61. /**
  62. * @brief
  63. */
  64. m_basicOrderModule.initialize(&m_canReceiver);
  65. m_basicOrderModule.regInputCtl([this](uint8_t id, bool &val) { return false; });
  66. m_basicOrderModule.regOutCtl([this](uint8_t id, bool val) {
  67. if (id == 0) {
  68. AirCompressorCtrl1.setState(val);
  69. return true;
  70. }
  71. if (id == 1) {
  72. AirCompressorCtrl2.setState(val);
  73. return true;
  74. }
  75. if (id == 2) {
  76. AirBlowerCtrl1.setState(val);
  77. return true;
  78. }
  79. if (id == 3) {
  80. AirBlowerCtrl2.setState(val);
  81. return true;
  82. }
  83. if (id == 4) {
  84. HeatingStripCtrl1.setState(val);
  85. return true;
  86. }
  87. if (id == 5) {
  88. HeatingStripCtrl2.setState(val);
  89. return true;
  90. }
  91. return false;
  92. });
  93. m_basicOrderModule.regReadAdcVal([this](uint8_t id, int32_t &val) {
  94. if (id == 0) {
  95. val = 0;
  96. return true;
  97. }
  98. if (id == 1) {
  99. val = 0;
  100. return true;
  101. }
  102. if (id == 2) {
  103. val = 0;
  104. return true;
  105. }
  106. return false;
  107. });
  108. ZLOGI(TAG, "init done");
  109. while (1) {
  110. ZHALCORE::getInstance()->loop();
  111. }
  112. }