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
36void 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 */
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 */
64 xf_delay_ms(1000);
65 }
66 XF_LOGI(TAG, "reboot!");
68}
69
70/* ==================== [Static Functions] ================================== */
void xf_main(void)
Definition xf_main.c:28
xf_us_t xf_sys_time_get_us(void)
获取系统时间的时间戳,单位微秒(us)
xf_ms_t xf_sys_time_get_ms(void)
获取系统时间的时间戳,单位毫秒(ms)
Definition xf_sys_time.c:96
xf_err_t xf_delay_ms(xf_ms_t n_ms)
毫秒级延时
Definition xf_sys_time.c:40
xf_err_t xf_delay_us(xf_us_t n_us)
微秒级延时
Definition xf_sys_time.c:57
__weak xf_err_t xf_sys_watchdog_enable(void)
开启看门狗
__weak xf_err_t xf_sys_watchdog_kick(void)
喂狗,防止看门狗超时叫
__weak void xf_sys_reboot(void)
软件系统重启
Definition xf_sys.c:30
#define TAG
Definition xf_main.c:24
#define EXAMPLE_DELAY_LOOP_COUNT
Definition xf_main.c:24
#define XF_LOGI(tag, format,...)
XF_US_TYPE xf_us_t
XF_MS_TYPE xf_ms_t