diff options
| author | guo <[email protected]> | 2022-12-03 12:07:44 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-12-03 12:07:44 +0800 |
| commit | ecf2d8215961ca7c539132b62a72df6072cc3e14 (patch) | |
| tree | 59005f0f74f2593c0435059264f624c862a89f55 /src/timer.c | |
| parent | aaf5462c6d4ae9466a0a8cd2a4bb00cfe1fef2f2 (diff) | |
sync branch rt-smart. (#6641)
* Synchronize the code of the rt mart branch to the master branch.
* TTY device
* Add lwP code from rt-smart
* Add vnode in DFS, but DFS will be re-write for rt-smart
* There are three libcpu for rt-smart:
* arm/cortex-a, arm/aarch64
* riscv64
Co-authored-by: Rbb666 <[email protected]>
Co-authored-by: zhkag <[email protected]>
Diffstat (limited to 'src/timer.c')
| -rw-r--r-- | src/timer.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/timer.c b/src/timer.c index ce11bf3518..5e200c0c95 100644 --- a/src/timer.c +++ b/src/timer.c @@ -502,7 +502,7 @@ rt_err_t rt_timer_start(rt_timer_t timer) { /* check whether timer thread is ready */ if ((_soft_timer_status == RT_SOFT_TIMER_IDLE) && - ((_timer_thread.stat & RT_THREAD_STAT_MASK) == RT_THREAD_SUSPEND)) + ((_timer_thread.stat & RT_THREAD_SUSPEND_MASK) == RT_THREAD_SUSPEND_MASK)) { /* resume timer thread to check soft timer */ rt_thread_resume(&_timer_thread); @@ -534,18 +534,21 @@ rt_err_t rt_timer_stop(rt_timer_t timer) { rt_base_t level; - /* parameter check */ + /* disable interrupt */ + level = rt_hw_interrupt_disable(); + + /* timer check */ RT_ASSERT(timer != RT_NULL); RT_ASSERT(rt_object_get_type(&timer->parent) == RT_Object_Class_Timer); if (!(timer->parent.flag & RT_TIMER_FLAG_ACTIVATED)) + { + rt_hw_interrupt_enable(level); return -RT_ERROR; + } RT_OBJECT_HOOK_CALL(rt_object_put_hook, (&(timer->parent))); - /* disable interrupt */ - level = rt_hw_interrupt_disable(); - _timer_remove(timer); /* change status */ timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED; @@ -610,6 +613,21 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg) case RT_TIMER_CTRL_GET_REMAIN_TIME: *(rt_tick_t *)arg = timer->timeout_tick; break; + case RT_TIMER_CTRL_GET_FUNC: + *(void **)arg = timer->timeout_func; + break; + + case RT_TIMER_CTRL_SET_FUNC: + timer->timeout_func = (void (*)(void*))arg; + break; + + case RT_TIMER_CTRL_GET_PARM: + *(void **)arg = timer->parameter; + break; + + case RT_TIMER_CTRL_SET_PARM: + timer->parameter = arg; + break; default: break; @@ -801,7 +819,7 @@ static void _timer_thread_entry(void *parameter) if (_timer_list_next_timeout(_soft_timer_list, &next_timeout) != RT_EOK) { /* no software timer exist, suspend self. */ - rt_thread_suspend(rt_thread_self()); + rt_thread_suspend_with_flag(rt_thread_self(), RT_UNINTERRUPTIBLE); rt_schedule(); } else |
