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