embkernel
 All Classes Functions Variables Typedefs Groups Pages
RtosTimer.cpp
1 //------------------------------------------------------------------------------
2 //This file is part of embKernel.
3 //See license.txt for the full license governing this code.
4 //------------------------------------------------------------------------------
8 #include "RtosTimer.hpp"
9 
14 void RtosTimer::set(Rtos::TICK timeout) {
15  if (timeout == Rtos::TICK_INFINITE) {
16  mState = INFINITE_TIMEOUT;
17  }
18  else {
19  mTimeout = Rtos::getTick() + timeout;
20  mState = COUNTING;
21  }
22 }
23 
29  switch (mState) {
30  case COUNTING:
31  if (Rtos::isElapsed(mTimeout)) {
32  mState = ELLAPSED;
33  return true;
34  }
35  return false;
36  case ELLAPSED:
37  return true;
38  case INFINITE_TIMEOUT:
39  return false;
40  }
41  return false;
42 }