main.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2006-2025, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2025-01-22 RT-Thread first version
  9. */
  10. #include <rtthread.h>
  11. #include <board.h>
  12. #include <rtdevice.h>
  13. #define DBG_ENABLE
  14. #define DBG_COLOR
  15. #define DBG_TAG "main"
  16. #define DBG_LVL DBG_LOG
  17. #include <rtdbg.h>
  18. #include <ledblink.h>
  19. #include <control.h>
  20. #include "beep.h"
  21. #include "hmi.h"
  22. #define CompileTime sprintf(device_status.driver_compile,"%s-%s",__DATE__,__TIME__) //编译时间,每次更新代码修改
  23. int clock_information(void);
  24. /* 2.9.48: memtrace 定义在 rt-thread/src/mem.c(MSH命令), 无头文件声明, 显式声明消除隐式声明告警 */
  25. int memtrace(int argc, char **argv);
  26. int main(void)
  27. {
  28. __HAL_RCC_PWR_CLK_ENABLE();
  29. __HAL_RCC_BKP_CLK_ENABLE();
  30. HAL_PWR_EnableBkUpAccess();
  31. uint16_t boot_flag = *(__IO uint16_t *)(BKP_BASE + 4 * 2); /* RTC_BKP_DR2, 16-bit */
  32. //打印boot_flag的值
  33. LOG_I("boot_flag:0x%04x\n",boot_flag);
  34. /* 清除 bootloader 的启动标志,表示 app 启动成功 */
  35. *(__IO uint16_t *)(0x40006C00 + 4 * 2) = 0x0000;
  36. CompileTime; //读取固件的编译时间
  37. led_add_device(LED0_PIN);
  38. led_set_level(1,0);
  39. clock_information();
  40. Beep_Tip(100);
  41. ctr_Heat(ON);
  42. Check_ParamConfig();
  43. //打印内存占用
  44. memtrace(0, NULL);
  45. while(1)
  46. {
  47. if(device_status.update_flag == 1)
  48. {
  49. rt_thread_mdelay(100);
  50. }else{
  51. rt_thread_mdelay(1000);
  52. }
  53. led_tog(1);
  54. }
  55. return RT_EOK;
  56. }