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.

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