Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaobo07
rt-thread
提交
36fc5520
R
rt-thread
项目概览
Xiaobo07
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
36fc5520
编写于
5月 17, 2013
作者:
wuyangyong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format code by Astyle.
上级
f7d1097e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
32 deletion
+32
-32
components/drivers/rtc/alarm.c
components/drivers/rtc/alarm.c
+32
-32
未找到文件。
components/drivers/rtc/alarm.c
浏览文件 @
36fc5520
...
...
@@ -61,7 +61,7 @@ static rt_err_t alarm_set(struct rt_alarm *alarm)
ret
=
rt_device_control
(
device
,
RT_DEVICE_CTRL_RTC_GET_ALARM
,
&
wkalarm
);
if
(
ret
==
RT_EOK
)
{
/*
/*
some RTC device like RX8025,it's alarms precision is 1 minute.
in this case,low level RTC driver should set wkalarm->tm_sec to 0.
*/
...
...
@@ -79,7 +79,7 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now)
rt_uint32_t
sec_alarm
,
sec_now
;
rt_bool_t
wakeup
=
RT_FALSE
;
time_t
timestamp
;
sec_alarm
=
alarm_mkdaysec
(
&
alarm
->
wktime
);
sec_now
=
alarm_mkdaysec
(
now
);
...
...
@@ -97,7 +97,7 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now)
alarm
->
flag
&=
~
RT_ALARM_STATE_START
;
alarm_set
(
alarm
);
wakeup
=
RT_TRUE
;
}
}
}
break
;
case
RT_ALARM_DAILY
:
...
...
@@ -129,10 +129,10 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now)
case
RT_ALARM_YAERLY
:
{
if
((
alarm
->
wktime
.
tm_mday
==
now
->
tm_mday
)
&&
\
(
alarm
->
wktime
.
tm_mon
==
now
->
tm_mon
))
(
alarm
->
wktime
.
tm_mon
==
now
->
tm_mon
))
{
if
((
sec_now
-
sec_alarm
)
<=
RT_ALARM_DELAY
)
wakeup
=
RT_TRUE
;
if
((
sec_now
-
sec_alarm
)
<=
RT_ALARM_DELAY
)
wakeup
=
RT_TRUE
;
}
}
break
;
...
...
@@ -142,7 +142,7 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now)
{
timestamp
=
time
(
RT_NULL
);
alarm
->
callback
(
alarm
,
timestamp
);
}
}
}
}
...
...
@@ -253,7 +253,7 @@ static rt_bool_t is_valid_date(struct tm *date)
}
if
((
date
->
tm_mday
<
1
)
||
\
(
date
->
tm_mday
>
days_of_year_month
(
date
->
tm_year
,
date
->
tm_mon
)))
(
date
->
tm_mday
>
days_of_year_month
(
date
->
tm_year
,
date
->
tm_mon
)))
{
return
(
RT_FALSE
);
}
...
...
@@ -351,7 +351,7 @@ static rt_err_t alarm_setup(rt_alarm_t alarm, struct tm *wktime)
goto
_exit
;
}
}
if
((
setup
->
tm_hour
==
23
)
&&
(
setup
->
tm_min
==
59
)
&&
(
setup
->
tm_sec
==
59
))
{
/*
...
...
@@ -363,7 +363,7 @@ static rt_err_t alarm_setup(rt_alarm_t alarm, struct tm *wktime)
/* set initialized state */
alarm
->
flag
|=
RT_ALARM_STATE_INITED
;
ret
=
RT_EOK
;
_exit:
return
(
ret
);
...
...
@@ -372,7 +372,7 @@ _exit:
/** \brief send a rtc alarm event
*
* \param dev pointer to RTC device(currently unused,you can ignore it)
* \param event RTC event(currently unused)
* \param event RTC event(currently unused)
* \return none
*/
void
rt_alarm_update
(
rt_device_t
dev
,
rt_uint32_t
event
)
...
...
@@ -391,25 +391,25 @@ rt_err_t rt_alarm_control(rt_alarm_t alarm, rt_uint8_t cmd, void *arg)
rt_err_t
ret
=
RT_ERROR
;
RT_ASSERT
(
alarm
!=
RT_NULL
);
rt_mutex_take
(
&
_container
.
mutex
,
RT_WAITING_FOREVER
);
switch
(
cmd
)
{
case
RT_ALARM_CTRL_MODIFY
:
{
struct
rt_alarm_setup
*
setup
;
RT_ASSERT
(
arg
!=
RT_NULL
);
RT_ASSERT
(
arg
!=
RT_NULL
);
setup
=
arg
;
rt_alarm_stop
(
alarm
);
alarm
->
flag
=
setup
->
flag
&
0xFF00
;
alarm
->
wktime
=
setup
->
wktime
;
ret
=
alarm_setup
(
alarm
,
&
alarm
->
wktime
);
ret
=
alarm_setup
(
alarm
,
&
alarm
->
wktime
);
}
break
;
break
;
}
rt_mutex_release
(
&
_container
.
mutex
);
rt_mutex_release
(
&
_container
.
mutex
);
return
(
ret
);
}
...
...
@@ -425,7 +425,7 @@ rt_err_t rt_alarm_start(rt_alarm_t alarm)
rt_err_t
ret
=
RT_ERROR
;
time_t
timestamp
;
struct
tm
now
;
if
(
alarm
==
RT_NULL
)
return
(
ret
);
rt_mutex_take
(
&
_container
.
mutex
,
RT_WAITING_FOREVER
);
...
...
@@ -433,12 +433,12 @@ rt_err_t rt_alarm_start(rt_alarm_t alarm)
{
if
(
alarm_setup
(
alarm
,
&
alarm
->
wktime
)
!=
RT_EOK
)
goto
_exit
;
}
}
if
((
alarm
->
flag
&
0x01
)
==
RT_ALARM_STATE_STOP
)
{
timestamp
=
time
(
RT_NULL
);
localtime_r
(
&
timestamp
,
&
now
);
alarm
->
flag
|=
RT_ALARM_STATE_START
;
/* set alarm */
if
(
_container
.
current
==
RT_NULL
)
...
...
@@ -490,7 +490,7 @@ _exit:
rt_err_t
rt_alarm_stop
(
rt_alarm_t
alarm
)
{
rt_err_t
ret
=
RT_ERROR
;
if
(
alarm
==
RT_NULL
)
return
(
ret
);
rt_mutex_take
(
&
_container
.
mutex
,
RT_WAITING_FOREVER
);
...
...
@@ -498,12 +498,12 @@ rt_err_t rt_alarm_stop(rt_alarm_t alarm)
goto
_exit
;
/* stop alarm */
alarm
->
flag
&=
~
RT_ALARM_STATE_START
;
if
(
_container
.
current
==
alarm
)
{
ret
=
alarm_set
(
alarm
);
_container
.
current
=
RT_NULL
;
}
}
if
(
ret
==
RT_EOK
)
alarm_update
(
0
);
...
...
@@ -522,10 +522,10 @@ _exit:
rt_err_t
rt_alarm_delete
(
rt_alarm_t
alarm
)
{
rt_err_t
ret
=
RT_ERROR
;
if
(
alarm
==
RT_NULL
)
return
(
ret
);
rt_mutex_take
(
&
_container
.
mutex
,
RT_WAITING_FOREVER
);
return
(
ret
);
rt_mutex_take
(
&
_container
.
mutex
,
RT_WAITING_FOREVER
);
/* stop the alarm */
alarm
->
flag
&=
~
RT_ALARM_STATE_START
;
if
(
_container
.
current
==
alarm
)
...
...
@@ -533,13 +533,13 @@ rt_err_t rt_alarm_delete(rt_alarm_t alarm)
ret
=
alarm_set
(
alarm
);
_container
.
current
=
RT_NULL
;
/* set new alarm if necessary */
alarm_update
(
0
);
alarm_update
(
0
);
}
rt_list_remove
(
&
alarm
->
list
);
rt_free
(
alarm
);
rt_mutex_release
(
&
_container
.
mutex
);
return
(
ret
);
}
...
...
@@ -551,18 +551,18 @@ rt_err_t rt_alarm_delete(rt_alarm_t alarm)
rt_alarm_t
rt_alarm_create
(
rt_alarm_callback_t
callback
,
struct
rt_alarm_setup
*
setup
)
{
struct
rt_alarm
*
alarm
;
if
(
setup
==
RT_NULL
)
return
(
RT_NULL
);
alarm
=
rt_malloc
(
sizeof
(
struct
rt_alarm
));
if
(
alarm
==
RT_NULL
)
return
(
RT_NULL
);
rt_list_init
(
&
alarm
->
list
);
alarm
->
wktime
=
setup
->
wktime
;
alarm
->
flag
=
setup
->
flag
&
0xFF00
;
alarm
->
callback
=
callback
;
rt_mutex_take
(
&
_container
.
mutex
,
RT_WAITING_FOREVER
);
rt_mutex_take
(
&
_container
.
mutex
,
RT_WAITING_FOREVER
);
rt_list_insert_after
(
&
_container
.
head
,
&
alarm
->
list
);
rt_mutex_release
(
&
_container
.
mutex
);
...
...
@@ -587,7 +587,7 @@ static void rt_alarmsvc_thread_init(void *param)
RT_EVENT_FLAG_OR
|
RT_EVENT_FLAG_CLEAR
,
RT_WAITING_FOREVER
,
&
recv
)
==
RT_EOK
)
{
alarm_update
(
recv
);
alarm_update
(
recv
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录