* @brief This function will detach a timer from timer management. * * @param timer is the timer to be detached * * @return the status of detach */
| 291 | * @return the status of detach |
| 292 | */ |
| 293 | rt_err_t rt_timer_detach(rt_timer_t timer) |
| 294 | { |
| 295 | rt_base_t level; |
| 296 | struct rt_spinlock *spinlock; |
| 297 | |
| 298 | /* parameter check */ |
| 299 | RT_ASSERT(timer != RT_NULL); |
| 300 | RT_ASSERT(rt_object_get_type(&timer->parent) == RT_Object_Class_Timer); |
| 301 | RT_ASSERT(rt_object_is_systemobject(&timer->parent)); |
| 302 | |
| 303 | spinlock = _timerlock_idx(timer); |
| 304 | level = rt_spin_lock_irqsave(spinlock); |
| 305 | |
| 306 | _timer_remove(timer); |
| 307 | /* stop timer */ |
| 308 | timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED; |
| 309 | |
| 310 | rt_spin_unlock_irqrestore(spinlock, level); |
| 311 | rt_object_detach(&(timer->parent)); |
| 312 | |
| 313 | return RT_EOK; |
| 314 | } |
| 315 | RTM_EXPORT(rt_timer_detach); |
| 316 | |
| 317 | #ifdef RT_USING_HEAP |