| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- /*
- * Copyright (c) 2006-2025, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- * 2025-01-22 RT-Thread first version
- */
- #include <rtthread.h>
- #include <board.h>
- #include <rtdevice.h>
- #define DBG_ENABLE
- #define DBG_COLOR
- #define DBG_TAG "main"
- #define DBG_LVL DBG_LOG
- #include <rtdbg.h>
- #include <ledblink.h>
- #include <control.h>
- #include "beep.h"
- #include "hmi.h"
- /* P3-2: memtrace() 在 rt-thread/src/mem.c 里定义(并已 MSH_CMD_EXPORT),
- 但 rtthread.h / finsh.h 都没有它的原型 -> 隐式声明。
- GCC14+ 默认 -Werror=implicit-function-declaration 会直接编不过, 这里补声明。 */
- extern int memtrace(int argc, char **argv);
- /* device_status 的**唯一真实定义**。
- 其余 .c 一律通过 control.h 里的 extern 声明引用, 不要再写第二份定义。 */
- Device_Status_typedef device_status;
- #define CompileTime sprintf(device_status.driver_compile,"%s-%s",__DATE__,__TIME__) //编译时间,每次更新代码修改
- int clock_information(void);
- int main(void)
- {
- __HAL_RCC_PWR_CLK_ENABLE();
- __HAL_RCC_BKP_CLK_ENABLE();
- HAL_PWR_EnableBkUpAccess();
- uint16_t boot_flag = *(__IO uint16_t *)(BKP_BASE + 4 * 2); /* RTC_BKP_DR2, 16-bit */
- //打印boot_flag的值
- LOG_I("boot_flag:0x%04x\n",boot_flag);
- /* 清除 bootloader 的启动标志,表示 app 启动成功 */
- *(__IO uint16_t *)(0x40006C00 + 4 * 2) = 0x0000;
- CompileTime; //读取固件的编译时间
- led_add_device(LED0_PIN);
- led_set_level(1,0);
- clock_information();
- Beep_Tip(100);
- #if DINGZHI_0722 == 0
- Check_ParamConfig();
- #endif
- //打印内存占用
- memtrace(0, NULL);
- /* 运行指示灯(LED0/PB3) 双闪图案(2026-10-15 同步 master led_pat_ms 时序):
- * 亮100 -> 灭100 -> 亮100 -> 灭500,循环;原实现为每 1s 翻转一次(无固定节奏)。
- * 主循环直接按时序走,不需要空闲钩子/新增定时器;改节奏只改下面 mdelay 值。 */
- while(1)
- {
- led_set_level(1, 1); rt_thread_mdelay(100);
- led_set_level(1, 0); rt_thread_mdelay(100);
- led_set_level(1, 1); rt_thread_mdelay(100);
- led_set_level(1, 0); rt_thread_mdelay(500);
- }
- return RT_EOK;
- }
|