XFusion API
v1.3.0
载入中...
搜索中...
未找到
xf_main.c
浏览该文件的文档.
1
17
/* ==================== [Includes] ========================================== */
18
19
#include "xf_sys.h"
20
21
/* ==================== [Defines] =========================================== */
22
23
#define TAG "main"
24
#define EXAMPLE_DELAY_LOOP_COUNT 20
26
/* ==================== [Typedefs] ========================================== */
27
28
/* ==================== [Static Prototypes] ================================= */
29
30
/* ==================== [Static Variables] ================================== */
31
32
/* ==================== [Macros] ============================================ */
33
34
/* ==================== [Global Functions] ================================== */
35
36
void
xf_main
(
void
)
37
{
38
xf_ms_t
ms_before =
xf_sys_time_get_ms
();
39
xf_delay_ms
(1000);
40
xf_ms_t
ms_after =
xf_sys_time_get_ms
();
41
42
xf_us_t
us_before =
xf_sys_time_get_us
();
43
xf_delay_us
(10);
44
xf_us_t
us_after =
xf_sys_time_get_us
();
45
46
XF_LOGI
(
TAG
,
"tick:ms_before:%llu\tms_after:%llu\tms_diff:%llu"
,
47
ms_before, ms_after, ms_after - ms_before);
48
49
XF_LOGI
(
TAG
,
"tick:us_before:%llu\tus_after:%llu\tus_diff:%llu"
,
50
us_before, us_after, us_after - us_before);
51
52
/* 确保开启了 watchdog */
53
xf_sys_watchdog_enable
();
54
xf_sys_watchdog_kick
();
55
XF_LOGI
(
TAG
,
"Will reboot in %d seconds."
,
EXAMPLE_DELAY_LOOP_COUNT
);
56
for
(
int
i =
EXAMPLE_DELAY_LOOP_COUNT
; i > 0; --i) {
57
XF_LOGI
(
TAG
,
"count: %d"
, i);
58
/*
59
测试 kick 看门狗是否有作用,
60
如果有作用,应当在 EXAMPLE_DELAY_LOOP_COUNT s 后
61
输出 `reboot!` 消息并重启。
62
*/
63
xf_sys_watchdog_kick
();
64
xf_delay_ms
(1000);
65
}
66
XF_LOGI
(
TAG
,
"reboot!"
);
67
xf_sys_reboot
();
68
}
69
70
/* ==================== [Static Functions] ================================== */
xf_main
void xf_main(void)
Definition
xf_main.c:28
xf_sys_time_get_us
xf_us_t xf_sys_time_get_us(void)
获取系统时间的时间戳,单位微秒(us)
Definition
xf_sys_time.c:104
xf_sys_time_get_ms
xf_ms_t xf_sys_time_get_ms(void)
获取系统时间的时间戳,单位毫秒(ms)
Definition
xf_sys_time.c:96
xf_delay_ms
xf_err_t xf_delay_ms(xf_ms_t n_ms)
毫秒级延时
Definition
xf_sys_time.c:40
xf_delay_us
xf_err_t xf_delay_us(xf_us_t n_us)
微秒级延时
Definition
xf_sys_time.c:57
xf_sys_watchdog_enable
__weak xf_err_t xf_sys_watchdog_enable(void)
开启看门狗
Definition
xf_sys_watchdog.c:30
xf_sys_watchdog_kick
__weak xf_err_t xf_sys_watchdog_kick(void)
喂狗,防止看门狗超时叫
Definition
xf_sys_watchdog.c:40
xf_sys_reboot
__weak void xf_sys_reboot(void)
软件系统重启
Definition
xf_sys.c:30
TAG
#define TAG
Definition
xf_main.c:24
EXAMPLE_DELAY_LOOP_COUNT
#define EXAMPLE_DELAY_LOOP_COUNT
Definition
xf_main.c:24
XF_LOGI
#define XF_LOGI(tag, format,...)
Definition
xf_log_uitls.h:44
xf_us_t
XF_US_TYPE xf_us_t
Definition
xf_sys_config_internal.h:42
xf_ms_t
XF_MS_TYPE xf_ms_t
Definition
xf_sys_config_internal.h:36
examples
system
sys
main
xf_main.c
生成于 2025年 一月 21日 星期二 17:25:09 , 为 XFusion API使用
1.9.8