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.

91 lines
2.1 KiB

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. #include <stddef.h>
  2. #include <stdio.h>
  3. #include "configs/device_id_mgr.hpp"
  4. #include "public_service/public_service.hpp"
  5. #include "sdk/sdk.hpp"
  6. #include "sysmgr/sys_mgr.hpp"
  7. //
  8. //
  9. #define TAG "main"
  10. using namespace std;
  11. using namespace iflytop;
  12. extern void umain();
  13. extern "C" {
  14. void StartDefaultTask(void const* argument) { umain(); }
  15. }
  16. static void board_init() {
  17. int32_t deviceId = zdevice_id_mgr_get_device_id();
  18. switch (deviceId) {
  19. default:
  20. common_hardware_init();
  21. break;
  22. }
  23. }
  24. static void board_post_init() {
  25. int32_t deviceId = zdevice_id_mgr_get_device_id();
  26. GService::inst()->initialize();
  27. switch (deviceId) {
  28. default:
  29. break;
  30. }
  31. }
  32. static iflytop::ZGPIO debuglight;
  33. static bool errorFlag;
  34. static inline void debugLightLoop() {
  35. static bool light = false;
  36. static uint32_t lastcall = 0;
  37. if (errorFlag) {
  38. if (zos_haspassedms(lastcall) > 30) {
  39. light = !light;
  40. debuglight.setState(light);
  41. lastcall = zos_get_tick();
  42. }
  43. } else {
  44. if (zos_haspassedms(lastcall) > 300) {
  45. light = !light;
  46. debuglight.setState(light);
  47. lastcall = zos_get_tick();
  48. }
  49. }
  50. }
  51. void umain() {
  52. //
  53. board_init();
  54. sdkinit();
  55. debuglight.initAsOutput(PC_DEBUG_LIGHT_GPIO, iflytop::ZGPIO::kMode_nopull, false, false);
  56. ZLOGI("SYS", "chip init ok");
  57. ZLOGI("SYS", "= manufacturer : %s", PC_MANUFACTURER);
  58. ZLOGI("SYS", "= project name : %s", PC_PROJECT_NAME);
  59. ZLOGI("SYS", "= version : %d", PC_VERSION);
  60. ZLOGI("SYS", "= freq : %d", HAL_RCC_GetSysClockFreq());
  61. ZLOGI("SYS", "= build time : %s", __DATE__ " " __TIME__);
  62. ZLOGI("SYS", "= device id : %d", zdevice_id_mgr_get_device_id());
  63. if (zdevice_id_mgr_get_device_id() <= 0) {
  64. ZLOGE("SYS", "device id is not set");
  65. errorFlag = true;
  66. } else {
  67. board_post_init();
  68. ZLOGI(TAG, "======================= sysinfo ======================= ");
  69. SysMgr::ins()->initedFinished();
  70. SysMgr::ins()->dumpSysInfo();
  71. ZLOGI(TAG, "=");
  72. }
  73. while (true) {
  74. GService::inst()->getZCanReceiver()->loop();
  75. osDelay(1);
  76. debugLightLoop();
  77. }
  78. }