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.

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