RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
dev_alarm.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2006-2023, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2012-10-27 heyuanjie87 first version.
9 * 2013-05-17 aozima initial alarm event & mutex in system init.
10 * 2020-10-15 zhangsz add alarm flags hour minute second.
11 */
12
13#ifndef __DEV_ALARM_H__
14#define __DEV_ALARM_H__
15
16#include <sys/time.h>
17#include <rtdef.h>
18
19#define RT_ALARM_TM_NOW -1 /* set the alarm tm_day,tm_mon,tm_sec,etc.
20 to now.we also call it "don't care" value */
21
22/* alarm flags */
23#define RT_ALARM_ONESHOT 0x000 /* only alarm once */
24#define RT_ALARM_DAILY 0x100 /* alarm everyday */
25#define RT_ALARM_WEEKLY 0x200 /* alarm weekly at Monday or Friday etc. */
26#define RT_ALARM_MONTHLY 0x400 /* alarm monthly at someday */
27#define RT_ALARM_YAERLY 0x800 /* alarm yearly at a certain date */
28#define RT_ALARM_HOUR 0x1000 /* alarm each hour at a certain min:second */
29#define RT_ALARM_MINUTE 0x2000 /* alarm each minute at a certain second */
30#define RT_ALARM_SECOND 0x4000 /* alarm each second */
32#define RT_ALARM_STATE_INITED 0x02
33#define RT_ALARM_STATE_START 0x01
34#define RT_ALARM_STATE_STOP 0x00
35
36/* alarm control cmd */
37#define RT_ALARM_CTRL_MODIFY 1 /* modify alarm time or alarm flag */
39typedef struct rt_alarm *rt_alarm_t;
40typedef void (*rt_alarm_callback_t)(rt_alarm_t alarm, time_t timestamp);
50};
52struct rt_alarm_setup
54 rt_uint32_t flag; /* alarm flag */
55 struct tm wktime; /* when will the alarm wake up user */
56};
64};
67 struct rt_alarm_setup *setup);
68rt_err_t rt_alarm_control(rt_alarm_t alarm, int cmd, void *arg);
73int rt_alarm_system_init(void);
74
75#endif /* __DEV_ALARM_H__ */
rt_err_t rt_alarm_start(rt_alarm_t alarm)
void(* rt_alarm_callback_t)(rt_alarm_t alarm, time_t timestamp)
int rt_alarm_system_init(void)
rt_alarm_t rt_alarm_create(rt_alarm_callback_t callback, struct rt_alarm_setup *setup)
void rt_alarm_update(rt_device_t dev, rt_uint32_t event)
rt_err_t rt_alarm_stop(rt_alarm_t alarm)
rt_err_t rt_alarm_control(rt_alarm_t alarm, int cmd, void *arg)
rt_err_t rt_alarm_delete(rt_alarm_t alarm)
struct rt_alarm * rt_alarm_t
struct rt_device * rt_device_t
rt_base_t rt_err_t
struct rt_list_node rt_list_t
unsigned int rt_uint32_t
struct rt_alarm * current
struct rt_event event
struct rt_mutex mutex
rt_uint32_t flag
rt_list_t list
void * user_data
rt_uint32_t flag
rt_alarm_callback_t callback
struct tm wktime