OSTmrDel
Description
OSTmrDel()
allows the user to delete a timer. If a timer was running it will be stopped and then deleted. If the timer has already timed out and is therefore stopped, it will simply be deleted.
It is up to the user to delete unused timers. If deleting a timer, you must not reference it again.
Files
os.h/os_tmr.c
Prototype
CPU_BOOLEAN OSTmrDel (OS_TMR *p_tmr, OS_ERR *p_err)
Arguments
p_tmr
is a pointer to the timer to be deleted.
p_err
a pointer to an error code and can be any of the following:
OS_ERR_NONE
If the timer was deleted.
OS_ERR_ILLEGAL_DEL_RUN_TIME
If OS_SAFETY_CRITICAL_IEC61508
is defined: you called this after calling OSStart()
and thus you are no longer allowed to delete kernel objects.
OS_ERR_OBJ_TYPE
If OS_CFG_OBJ_TYPE_CHK_EN
is set to DEF_ENABLED
in os_cfg.h
: if the user did not pass a pointer to a timer.
OS_ERR_OS_NOT_RUNNING
If OS_CFG_INVALID_OS_CALLS_CHK_EN
is set to DEF_ENABLED
in os_cfg.h
: if µC/OS-III is not running yet.
OS_ERR_TMR_INACTIVE
p_tmr
is pointing to an inactive timer. In other words, this error appears when pointing to a timer that has been deleted.
OS_ERR_TMR_INVALID
If OS_CFG_ARG_CHK_EN
is set to DEF_ENABLED
in os_cfg.h
: if p_tmr
is a NULL
pointer.
OS_ERR_TMR_INVALID_STATE
If the timer is in an invalid state.
OS_ERR_TMR_ISR
If OS_CFG_CALLED_FROM_ISR_CHK_EN
set to DEF_ENABLED
in os_cfg.h
: This function is called from an ISR, which is not allowed.
Returned Values
DEF_TRUE
if the timer was deleted, DEF_FALSE
if not or an error occurred.
Required Configuration
OS_CFG_TMR_EN
and OS_CFG_TMR_DEL_EN
must be enabled in os_cfg.h
. Refer to µC-OS-III Configuration Manual.
Callers
Application.
Notes/Warnings
- Do not call this function from an ISR.
- When deleting a timer, do not reference it again unless you re-create the timer by calling
OSTmrCreate()
.
Example Usage
OS_TMR CloseDoorTmr; void Task (void *p_arg) { OS_ERR err; CPU_BOOLEAN deleted; (void)&p_arg; while (DEF_ON) { deleted = OSTmrDel(&CloseDoorTmr, &err); /* Check "err" */ : : } }