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.

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