Versions Compared

Key

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

...

Files

os.h/os_sem.c

Prototype

Code Block
OS_SEM_CTR  OSSemPend (OS_SEM   *p_sem,
                       OS_TICK   timeout,
                       OS_OPT    opt,
                       CPU_TS   *p_ts,
                       OS_ERR   *p_err)

Arguments

p_sem

is a pointer to the semaphore.

...

  1. Semaphores must be created before they are used.

Example Usage

Code Block
titleOSSemPend() example usage
          OS_SEM  SwSem;
           
           
          void DispTask (void *p_arg)
          {
              OS_ERR      err;
              CPU_TS      ts;
              OS_SEM_CTR  ctr;
           
              (void)&p_arg;
              while (DEF_ON) {
                  :
                  :
                  ctr = OSSemPend(&SwSem,
                                   0,
                                   OS_OPT_PEND_BLOCKING,
                                  &ts,
                                  &err);
                  /* Check "err" */
                  :
                  :
              }
          }