正点原子开发板 alientek_develop_board cancmder
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.

137 lines
3.8 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
  1. #include "main.hpp"
  2. #include <stddef.h>
  3. #include <stdio.h>
  4. //
  5. #include "sdk/os/zos.hpp"
  6. #include "sdk\components\step_motor_45\step_motor_45.hpp"
  7. #include "sdk\components\step_motor_45\step_motor_45_scheduler.hpp"
  8. #define TAG "main"
  9. namespace iflytop {
  10. Main gmain;
  11. };
  12. using namespace iflytop;
  13. using namespace std;
  14. extern "C" {
  15. void StartDefaultTask(void const* argument) { umain(); }
  16. }
  17. /*******************************************************************************
  18. * *
  19. *******************************************************************************/
  20. static chip_cfg_t chipcfg = {
  21. .us_dleay_tim = &DELAY_US_TIMER,
  22. .tim_irq_scheduler_tim = &TIM_IRQ_SCHEDULER_TIMER,
  23. .huart = &DEBUG_UART,
  24. .debuglight = DEBUG_LIGHT_GPIO,
  25. };
  26. static StepMotor45::cfg_t cfg1 = {
  27. .max_pos = -1,
  28. .enable_zero_limit = false,
  29. .enable_max_pos_limit = false,
  30. .mirror = false,
  31. .zeroPin = PinNull,
  32. .zeroPinMirror = false,
  33. .driverPin = {PB15, PD11, PD12, PD13},
  34. .driverPinMirror = false,
  35. };
  36. static StepMotor45::cfg_t cfg2 = {
  37. .max_pos = -1,
  38. .enable_zero_limit = false,
  39. .enable_max_pos_limit = false,
  40. .mirror = false,
  41. .zeroPin = PinNull,
  42. .zeroPinMirror = false,
  43. .driverPin = {PG2, PG3, PG4, PG5},
  44. .driverPinMirror = false,
  45. };
  46. static StepMotor45::cfg_t cfg3 = {
  47. .max_pos = -1,
  48. .enable_zero_limit = false,
  49. .enable_max_pos_limit = false,
  50. .mirror = false,
  51. .zeroPin = PinNull,
  52. .zeroPinMirror = false,
  53. .driverPin = {PG6, PG7, PG8, PC6},
  54. .driverPinMirror = false,
  55. };
  56. static StepMotor45::cfg_t cfg4 = {
  57. .max_pos = -1,
  58. .enable_zero_limit = false,
  59. .enable_max_pos_limit = false,
  60. .mirror = false,
  61. .zeroPin = PinNull,
  62. .zeroPinMirror = false,
  63. .driverPin = {PC7, PC8, PC9, PA8},
  64. .driverPinMirror = false,
  65. };
  66. static StepMotor45::cfg_t cfg5 = {
  67. .max_pos = -1,
  68. .enable_zero_limit = false,
  69. .enable_max_pos_limit = false,
  70. .mirror = false,
  71. .zeroPin = PinNull,
  72. .zeroPinMirror = false,
  73. .driverPin = {PA13, PA14, PA15, PC10},
  74. .driverPinMirror = false,
  75. };
  76. /*******************************************************************************
  77. * *
  78. *******************************************************************************/
  79. static StepMotor45 g_step_motor45_1;
  80. static StepMotor45 g_step_motor45_2;
  81. static StepMotor45 g_step_motor45_3;
  82. static StepMotor45 g_step_motor45_4;
  83. static StepMotor45 g_step_motor45_5;
  84. void Main::run() {
  85. /*******************************************************************************
  86. * ϵͳʼ *
  87. *******************************************************************************/
  88. chip_init(&chipcfg);
  89. zos_cfg_t zoscfg;
  90. zos_init(&zoscfg);
  91. g_step_motor45_1.initialize(cfg1);
  92. g_step_motor45_2.initialize(cfg2);
  93. g_step_motor45_3.initialize(cfg3);
  94. g_step_motor45_4.initialize(cfg4);
  95. g_step_motor45_5.initialize(cfg5);
  96. StepMotor45Scheduler step_motor45_scheduler;
  97. step_motor45_scheduler.initialize(&htim10, 1000);
  98. step_motor45_scheduler.addMotor(&g_step_motor45_1);
  99. step_motor45_scheduler.addMotor(&g_step_motor45_2);
  100. step_motor45_scheduler.addMotor(&g_step_motor45_3);
  101. step_motor45_scheduler.addMotor(&g_step_motor45_4);
  102. step_motor45_scheduler.addMotor(&g_step_motor45_5);
  103. // g_step_motor45_1.rotate(true, 1000);
  104. step_motor45_scheduler.start();
  105. while (true) {
  106. OSDefaultSchduler::getInstance()->loop();
  107. }
  108. }