The code in Common\Delays.fth allows you to handle time delays specified in milliseconds. If you use the multitasker or Common\Timebase.fth, Common\Delays.fth should be compiled after them.
: pause \ -- ; multitasker hook
Allows the sytem multitasker to get a look in. If the
multitasker has not been compiled, PAUSE
is defined
as a compiler NOOP
.
0 value ticks \ -- n
Return current clock value in milliseconds. This value
can treated as a 32 bit unsigned value that will wrap
when it overflows. Compiled if not already defined.
: later \ n -- n'
Generates the timebase value for termination in
n millseconds time.
: expired \ n -- flag ; true if timed out
Flag is returned true if the timebase value n has timed out.
N.B. Calls PAUSE
.
: timedout? \ n -- flag ; true if timed out
Flag is returned true if the timebase value n has timed out.
TIMEDOUT?
does not call PAUSE
, so it can be used
in interrupt handlers. In particular, TIMEDOUT?
should
be used rather than EXPIRED
inside timer action words
to reduce timer jitter.
: ms \ n --
Waits for n milliseconds. Uses PAUSE
through
EXPIRED
.