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.

144 lines
4.3 KiB

2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
  1. #include <stddef.h>
  2. #include <stdio.h>
  3. #include "configs/device_id_mgr.hpp"
  4. #include "public_service/public_service.hpp"
  5. #include "sdk/chip/chip.hpp"
  6. #include "sdk/os/zos.hpp"
  7. #include "sysmgr/sys_mgr.hpp"
  8. //
  9. #include "subboards/subboard200_ext_tmc5160/subboard200_ext_tmc5160.hpp"
  10. #include "subboards/subboard200_ext_tmc5160/subboard200_ext_tmc5160_board.h"
  11. #include "subboards/subboard20_plate_clamp_case/subboard20_plate_clamp_case.hpp"
  12. #include "subboards/subboard20_plate_clamp_case/subboard20_plate_clamp_case_board.h"
  13. #include "subboards/subboard30_shake_module/subboard30_shake_module.hpp"
  14. #include "subboards/subboard30_shake_module/subboard30_shake_module_board.h"
  15. #include "subboards/subboard60_inlet_and_outlet_module/subboard60_inlet_and_outlet_module.hpp"
  16. #include "subboards/subboard60_inlet_and_outlet_module/subboard60_inlet_and_outlet_module_board.h"
  17. #include "subboards/subboard70_incubation_turntable/subboard70_incubation_turntable.hpp"
  18. #include "subboards/subboard70_incubation_turntable/subboard70_incubation_turntable_board.h"
  19. #include "subboards/subboard80_cliptip/subboard80_cliptip.hpp"
  20. #include "subboards/subboard80_cliptip/subboard80_cliptip_board.h"
  21. #include "subboards/subboard90_optical_module/subboard90_optical_module.hpp"
  22. #include "subboards/subboard90_optical_module/subboard90_optical_module_board.h"
  23. //
  24. #define TAG "main"
  25. using namespace std;
  26. using namespace iflytop;
  27. extern void umain();
  28. extern "C" {
  29. void StartDefaultTask(void const* argument) { umain(); }
  30. }
  31. int32_t deviceId = 0;
  32. static void board_init() {
  33. switch (deviceId) {
  34. case 20: // 板夹仓
  35. subboard20_plate_clamp_case_board_init();
  36. break;
  37. case 30: // 摇匀模组
  38. subboard30_shake_module_board_init();
  39. break;
  40. case 60: // 进出料模组
  41. subboard60_inlet_and_outlet_module_board_init();
  42. break;
  43. case 70: // 孵化转盘
  44. subboard70_incubation_turntable_board_init();
  45. break;
  46. case 80:
  47. subboard80_cliptip_board_init();
  48. break;
  49. case 90:
  50. subboard90_optical_module_board_init();
  51. break;
  52. case 200:
  53. subboard200_ext_tmc5160_board_init();
  54. break;
  55. default:
  56. common_hardware_init();
  57. break;
  58. }
  59. }
  60. static void board_post_init() {
  61. GService::inst()->initialize();
  62. switch (deviceId) {
  63. case 20:
  64. Subboard20PlateClampCase::ins()->initialize();
  65. break;
  66. case 30: // 摇匀模组
  67. Subboard30ShakeModule::ins()->initialize();
  68. break;
  69. case 60: // 进出料模组
  70. Subboard60InjectAndOutletModule::ins()->initialize();
  71. break;
  72. case 70: // 孵化转盘
  73. Subboard70IncubationTurntable::ins()->initialize();
  74. break;
  75. case 80:
  76. Subboard80Cliptip::ins()->initialize();
  77. break;
  78. case 200:
  79. Subboard200ExtTmc5160::ins()->initialize();
  80. break;
  81. // case 90:
  82. // Subboard90OpticalModule::ins()->initialize();
  83. // break;
  84. default:
  85. break;
  86. }
  87. }
  88. void umain() {
  89. deviceId = zdevice_id_mgr_get_device_id();
  90. board_init();
  91. Pin_t debugLight = PC_DEBUG_LIGHT_GPIO;
  92. if (deviceId == 20 || deviceId == 70) {
  93. debugLight = PC_SUBBOARD_20_70_LIGHT_GPIO;
  94. }
  95. zos_cfg_t zoscfg = {0};
  96. chip_cfg_t chipcfg = {};
  97. chipcfg.us_dleay_tim = &PC_SYS_DELAY_US_TIMER;
  98. chipcfg.tim_irq_scheduler_tim = &PC_SYS_TIM_IRQ_SCHEDULER_TIMER;
  99. chipcfg.huart = &PC_DEBUG_UART;
  100. chipcfg.debuglight = debugLight;
  101. chip_init(&chipcfg);
  102. zos_init(&zoscfg);
  103. zdevice_id_mgr_init();
  104. ZEARLY_LOGI("SYS", "chip init ok");
  105. ZEARLY_LOGI("SYS", "= manufacturer : %s", PC_MANUFACTURER);
  106. ZEARLY_LOGI("SYS", "= project name : %s", PC_PROJECT_NAME);
  107. ZEARLY_LOGI("SYS", "= version : %d", PC_VERSION);
  108. ZEARLY_LOGI("SYS", "= freq : %d", HAL_RCC_GetSysClockFreq());
  109. ZEARLY_LOGI("SYS", "= build time : %s", __DATE__ " " __TIME__);
  110. ZEARLY_LOGI("SYS", "= device id : %d", deviceId);
  111. if (deviceId <= 0) {
  112. chip_set_error();
  113. ZEARLY_LOGE("SYS", "device id is not set");
  114. while (true) {
  115. zos_delay(1);
  116. }
  117. }
  118. board_post_init();
  119. ZLOGI(TAG, "======================= sysinfo ======================= ");
  120. SysMgr::ins()->initedFinished();
  121. SysMgr::ins()->dumpSysInfo();
  122. ZLOGI(TAG, "=");
  123. while (true) {
  124. GService::inst()->getZCanReceiver()->loop();
  125. zos_delay(1);
  126. }
  127. }