Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Files

os.h/os_tmr.c

Prototype

Code Block
void  OSTmrCreate (OS_TMR               *p_tmr,
                   CPU_CHAR             *p_name,
                   OS_TICK               dly,
                   OS_TICK               period,
                   OS_OPT                opt,
                   OS_TMR_CALLBACK_PTR   p_callback,
                   void                 *p_callback_arg,
                   OS_ERR               *p_err)

Arguments

p_tmr

is a pointer to the timer-control block of the desired timer. It is assumed that storage for the timer will be allocated in the application. In other words, you should declare a “global” variable as follows, and pass a pointer to this variable to OSTmrCreate():

...

  1. Do not call this function from an ISR.
  2. The timer is not started when it is created. To start the timer, simply call OSTmrStart().
  3. Do not make blocking calls within callback functions.
  4. Keep callback functions as short as possible.

Example Usage

Code Block
titleOSTmrCreate() example usage
          OS_TMR  CloseDoorTmr;
           
           
          void Task (void *p_arg)
          {
              OS_ERR   err;
           
           
              (void)&p_arg;
              while (DEF_ON) {
                  OSTmrCreate(&CloseDoorTmr,         /* p_tmr          */
                             "Door close",           /* p_name         */
                              10,                    /* dly            */
                              100,                   /* period         */
                              OS_OPT_TMR_PERIODIC,   /* opt            */
                              DoorCloseFnct,         /* p_callback     */
                              0,                     /* p_callback_arg */
                             &err);                  /* p_err          */
                  /* Check "err" */
                  :
                  :
              }
          }
           
           
          void  DoorCloseFnct (OS_TMR  *p_tmr,
                               void    *p_arg)
          {
              /* Close the door! */
          }